refactor: update deno_doc, use prismjs, remove internal reference html generation logic (#26885)
Some checks are pending
ci / pre-build (push) Waiting to run
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (aarch64, test, linux, debug, ubicloud-standard-16-arm) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (aarch64, test, linux, release, ubicloud-standard-16-arm, true) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (aarch64, test, macos, debug, ${{ github.repository == 'denoland/deno' && startsWith(github.ref, 'refs/tags/') && 'self-hosted' || 'macos-14' }}) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (aarch64, test, macos, release, ${{ (!contains(github.event.pull_request.labels.*.name, 'ci-full') && (github.event_name == 'pull_request')) && 'ubuntu-24.04' || github.reposit… (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, bench, linux, release, ${{ (!contains(github.event.pull_request.labels.*.name, 'ci-full') && (github.event_name == 'pull_request' && !contains(github.event.pull_reques… (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, lint, linux, debug, ubuntu-24.04) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, lint, macos, debug, macos-13) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, lint, windows, debug, windows-2022) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, linux, debug, ubuntu-24.04, true) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, linux, release, ${{ github.repository == 'denoland/deno' && 'ubuntu-24.04-xl' || 'ubuntu-24.04' }}, true, ${{ !startsWith(github.ref, 'refs/tags/') }}) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, macos, debug, macos-13) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, macos, release, ${{ (!contains(github.event.pull_request.labels.*.name, 'ci-full') && (github.event_name == 'pull_request')) && 'ubuntu-24.04' || 'macos-13' }}, … (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, windows, debug, windows-2022) (push) Blocked by required conditions
ci / ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}-${{ matrix.arch }} (x86_64, test, windows, release, ${{ (!contains(github.event.pull_request.labels.*.name, 'ci-full') && (github.event_name == 'pull_request')) && 'ubuntu-24.04' || github.reposi… (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

This commit is contained in:
Leo Kettmeir 2024-11-19 08:56:04 -08:00 committed by GitHub
parent 186b52731c
commit 628816448e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 291 additions and 185 deletions

View File

@ -31,6 +31,8 @@
"cli/tsc/dts/lib.scripthost.d.ts", "cli/tsc/dts/lib.scripthost.d.ts",
"cli/tsc/dts/lib.webworker*.d.ts", "cli/tsc/dts/lib.webworker*.d.ts",
"cli/tsc/dts/typescript.d.ts", "cli/tsc/dts/typescript.d.ts",
"cli/tools/doc/prism.css",
"cli/tools/doc/prism.js",
"ext/websocket/autobahn/reports", "ext/websocket/autobahn/reports",
"gh-pages", "gh-pages",
"target", "target",

226
Cargo.lock generated
View File

@ -128,6 +128,19 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "ammonia"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab99eae5ee58501ab236beb6f20f6ca39be615267b014899c89b2f0bc18a459"
dependencies = [
"html5ever",
"maplit",
"once_cell",
"tendril",
"url",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -882,9 +895,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]] [[package]]
name = "comrak" name = "comrak"
version = "0.28.0" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c93ab3577cca16b4a1d80a88c2e0cd8b6e969e51696f0bbb0d1dcb0157109832" checksum = "d8c32ff8b21372fab0e9ecc4e42536055702dc5faa418362bffd1544f9d12637"
dependencies = [ dependencies = [
"caseless", "caseless",
"derive_builder", "derive_builder",
@ -1540,27 +1553,33 @@ dependencies = [
[[package]] [[package]]
name = "deno_doc" name = "deno_doc"
version = "0.156.0" version = "0.160.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2585b98d6ad76dae30bf2d7b6d71b8363cae041158b8780d14a2f4fe17590a61" checksum = "db2baa33e5d1ed235209c2990f5fe9644bac6b9e7bcb789dd92894f907b09ad7"
dependencies = [ dependencies = [
"ammonia",
"anyhow", "anyhow",
"cfg-if", "cfg-if",
"comrak", "comrak",
"deno_ast", "deno_ast",
"deno_graph", "deno_graph",
"deno_path_util",
"futures", "futures",
"handlebars", "handlebars",
"html-escape", "html-escape",
"import_map", "import_map",
"indexmap 2.3.0", "indexmap 2.3.0",
"itoa", "itoa",
"js-sys",
"lazy_static", "lazy_static",
"percent-encoding",
"regex", "regex",
"serde", "serde",
"serde-wasm-bindgen",
"serde_json", "serde_json",
"syntect",
"termcolor", "termcolor",
"url",
"wasm-bindgen",
] ]
[[package]] [[package]]
@ -1642,9 +1661,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_graph" name = "deno_graph"
version = "0.84.1" version = "0.85.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd4f4a14aa069087be41c2998077b0453f0191747898f96e6343f700abfc2c18" checksum = "9d097305aba3f119781fe82b4d5a85a1ad10c586a388ee4d754e5bf82901cc5c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1667,6 +1686,7 @@ dependencies = [
"thiserror", "thiserror",
"twox-hash", "twox-hash",
"url", "url",
"wasm_dep_analyzer",
] ]
[[package]] [[package]]
@ -3226,6 +3246,16 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]]
name = "futf"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843"
dependencies = [
"mac",
"new_debug_unreachable",
]
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.30" version = "0.3.30"
@ -3753,6 +3783,20 @@ dependencies = [
"utf8-width", "utf8-width",
] ]
[[package]]
name = "html5ever"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4"
dependencies = [
"log",
"mac",
"markup5ever",
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]] [[package]]
name = "http" name = "http"
version = "0.2.12" version = "0.2.12"
@ -4465,6 +4509,12 @@ dependencies = [
"serde_repr", "serde_repr",
] ]
[[package]]
name = "mac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]] [[package]]
name = "malloc_buf" name = "malloc_buf"
version = "0.0.6" version = "0.0.6"
@ -4487,6 +4537,26 @@ dependencies = [
"tiny_pretty", "tiny_pretty",
] ]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "markup5ever"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45"
dependencies = [
"log",
"phf",
"phf_codegen",
"string_cache",
"string_cache_codegen",
"tendril",
]
[[package]] [[package]]
name = "markup_fmt" name = "markup_fmt"
version = "0.15.0" version = "0.15.0"
@ -4899,28 +4969,6 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "onig"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
"bitflags 1.3.2",
"libc",
"once_cell",
"onig_sys",
]
[[package]]
name = "onig_sys"
version = "69.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7"
dependencies = [
"cc",
"pkg-config",
]
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
version = "0.3.1" version = "0.3.1"
@ -5266,7 +5314,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [ dependencies = [
"phf_macros", "phf_macros",
"phf_shared", "phf_shared 0.11.2",
]
[[package]]
name = "phf_codegen"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
]
[[package]]
name = "phf_generator"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared 0.10.0",
"rand",
] ]
[[package]] [[package]]
@ -5275,7 +5343,7 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
dependencies = [ dependencies = [
"phf_shared", "phf_shared 0.11.2",
"rand", "rand",
] ]
@ -5285,13 +5353,22 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [ dependencies = [
"phf_generator", "phf_generator 0.11.2",
"phf_shared", "phf_shared 0.11.2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.87", "syn 2.0.87",
] ]
[[package]]
name = "phf_shared"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096"
dependencies = [
"siphasher",
]
[[package]] [[package]]
name = "phf_shared" name = "phf_shared"
version = "0.11.2" version = "0.11.2"
@ -5414,6 +5491,12 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]] [[package]]
name = "pretty_assertions" name = "pretty_assertions"
version = "1.4.0" version = "1.4.0"
@ -6364,6 +6447,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde-wasm-bindgen"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e"
dependencies = [
"js-sys",
"serde",
"wasm-bindgen",
]
[[package]] [[package]]
name = "serde_bytes" name = "serde_bytes"
version = "0.11.14" version = "0.11.14"
@ -6725,6 +6819,32 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "string_cache"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"
dependencies = [
"new_debug_unreachable",
"once_cell",
"parking_lot",
"phf_shared 0.10.0",
"precomputed-hash",
"serde",
]
[[package]]
name = "string_cache_codegen"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
"proc-macro2",
"quote",
]
[[package]] [[package]]
name = "string_enum" name = "string_enum"
version = "0.4.4" version = "0.4.4"
@ -7283,26 +7403,6 @@ dependencies = [
"syn 2.0.87", "syn 2.0.87",
] ]
[[package]]
name = "syntect"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1"
dependencies = [
"bincode",
"bitflags 1.3.2",
"flate2",
"fnv",
"once_cell",
"onig",
"regex-syntax",
"serde",
"serde_derive",
"serde_json",
"thiserror",
"walkdir",
]
[[package]] [[package]]
name = "tap" name = "tap"
version = "1.0.1" version = "1.0.1"
@ -7332,6 +7432,17 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "tendril"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0"
dependencies = [
"futf",
"mac",
"utf-8",
]
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.4.1" version = "1.4.1"
@ -8167,6 +8278,15 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "wasm_dep_analyzer"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f270206a91783fd90625c8bb0d8fbd459d0b1d1bf209b656f713f01ae7c04b8"
dependencies = [
"thiserror",
]
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.69" version = "0.3.69"

View File

@ -72,8 +72,8 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa
deno_cache_dir.workspace = true deno_cache_dir.workspace = true
deno_config.workspace = true deno_config.workspace = true
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.156.0", default-features = false, features = ["rust", "html", "syntect"] } deno_doc = { version = "0.160.0", features = ["rust", "comrak"] }
deno_graph = { version = "=0.84.1" } deno_graph = { version = "=0.85.0" }
deno_lint = { version = "=0.68.0", features = ["docs"] } deno_lint = { version = "=0.68.0", features = ["docs"] }
deno_lockfile.workspace = true deno_lockfile.workspace = true
deno_npm.workspace = true deno_npm.workspace = true

View File

@ -71,6 +71,7 @@ fn get_module_graph_error_class(err: &ModuleGraphError) -> &'static str {
| JsrLoadError::UnknownExport { .. } => "NotFound", | JsrLoadError::UnknownExport { .. } => "NotFound",
}, },
}, },
ModuleError::WasmParseErr(_, _) => "SyntaxError",
}, },
} }
} }

View File

@ -552,6 +552,7 @@ impl<TGraphContainer: ModuleGraphContainer>
) )
} }
None => specifier.into_owned(), None => specifier.into_owned(),
Some(Module::Wasm(_)) => todo!("@dsherret"),
}; };
Ok(specifier) Ok(specifier)
} }
@ -722,6 +723,7 @@ impl<TGraphContainer: ModuleGraphContainer>
| deno_graph::Module::Npm(_), | deno_graph::Module::Npm(_),
) )
| None => Ok(None), | None => Ok(None),
Some(deno_graph::Module::Wasm(_)) => todo!("@dsherret"),
} }
} }

View File

@ -651,6 +651,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
deno_graph::Module::Npm(_) deno_graph::Module::Npm(_)
| deno_graph::Module::Node(_) | deno_graph::Module::Node(_)
| deno_graph::Module::External(_) => (None, MediaType::Unknown), | deno_graph::Module::External(_) => (None, MediaType::Unknown),
deno_graph::Module::Wasm(_) => todo!("@dsherret"),
}; };
if module.specifier().scheme() == "file" { if module.specifier().scheme() == "file" {
let file_path = deno_path_util::url_to_file_path(module.specifier())?; let file_path = deno_path_util::url_to_file_path(module.specifier())?;

View File

@ -383,6 +383,7 @@ fn get_check_hash(
Module::External(module) => { Module::External(module) => {
hasher.write_str(module.specifier.as_str()); hasher.write_str(module.specifier.as_str());
} }
Module::Wasm(_) => todo!("@dsherret"),
} }
} }
@ -441,6 +442,7 @@ fn get_tsc_roots(
| Module::Node(_) | Module::Node(_)
| Module::Npm(_) | Module::Npm(_)
| Module::Json(_) => None, | Module::Json(_) => None,
Module::Wasm(_) => todo!("@dsherret"),
} }
} }

View File

@ -21,6 +21,8 @@ use deno_core::error::AnyError;
use deno_core::serde_json; use deno_core::serde_json;
use deno_doc as doc; use deno_doc as doc;
use deno_doc::html::UrlResolveKind; use deno_doc::html::UrlResolveKind;
use deno_doc::html::UsageComposer;
use deno_doc::html::UsageComposerEntry;
use deno_graph::source::NullFileSystem; use deno_graph::source::NullFileSystem;
use deno_graph::EsParser; use deno_graph::EsParser;
use deno_graph::GraphKind; use deno_graph::GraphKind;
@ -35,6 +37,9 @@ use std::sync::Arc;
const JSON_SCHEMA_VERSION: u8 = 1; const JSON_SCHEMA_VERSION: u8 = 1;
const PRISM_CSS: &str = include_str!("./doc/prism.css");
const PRISM_JS: &str = include_str!("./doc/prism.js");
async fn generate_doc_nodes_for_builtin_types( async fn generate_doc_nodes_for_builtin_types(
doc_flags: DocFlags, doc_flags: DocFlags,
parser: &dyn EsParser, parser: &dyn EsParser,
@ -312,10 +317,6 @@ impl deno_doc::html::HrefResolver for DocResolver {
None None
} }
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
current_resolve.get_file().map(|file| file.path.to_string())
}
fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> { fn resolve_source(&self, location: &deno_doc::Location) -> Option<String> {
Some(location.filename.to_string()) Some(location.filename.to_string())
} }
@ -350,105 +351,30 @@ impl deno_doc::html::HrefResolver for DocResolver {
} }
} }
struct DenoDocResolver(bool); struct DocComposer;
impl deno_doc::html::HrefResolver for DenoDocResolver { impl UsageComposer for DocComposer {
fn resolve_path( fn is_single_mode(&self) -> bool {
true
}
fn compose(
&self, &self,
current: UrlResolveKind, current_resolve: UrlResolveKind,
target: UrlResolveKind, usage_to_md: deno_doc::html::UsageToMd,
) -> String { ) -> IndexMap<UsageComposerEntry, String> {
let path = deno_doc::html::href_path_resolve(current, target);
if self.0 {
if let Some(path) = path
.strip_suffix("index.html")
.or_else(|| path.strip_suffix(".html"))
{
return path.to_owned();
}
}
path
}
fn resolve_global_symbol(&self, _symbol: &[String]) -> Option<String> {
None
}
fn resolve_import_href(
&self,
_symbol: &[String],
_src: &str,
) -> Option<String> {
None
}
fn resolve_usage(&self, _current_resolve: UrlResolveKind) -> Option<String> {
None
}
fn resolve_source(&self, _location: &deno_doc::Location) -> Option<String> {
None
}
fn resolve_external_jsdoc_module(
&self,
_module: &str,
_symbol: Option<&str>,
) -> Option<(String, String)> {
None
}
}
struct NodeDocResolver(bool);
impl deno_doc::html::HrefResolver for NodeDocResolver {
fn resolve_path(
&self,
current: UrlResolveKind,
target: UrlResolveKind,
) -> String {
let path = deno_doc::html::href_path_resolve(current, target);
if self.0 {
if let Some(path) = path
.strip_suffix("index.html")
.or_else(|| path.strip_suffix(".html"))
{
return path.to_owned();
}
}
path
}
fn resolve_global_symbol(&self, _symbol: &[String]) -> Option<String> {
None
}
fn resolve_import_href(
&self,
_symbol: &[String],
_src: &str,
) -> Option<String> {
None
}
fn resolve_usage(&self, current_resolve: UrlResolveKind) -> Option<String> {
current_resolve current_resolve
.get_file() .get_file()
.map(|file| format!("node:{}", file.path)) .map(|current_file| {
} IndexMap::from([(
UsageComposerEntry {
fn resolve_source(&self, _location: &deno_doc::Location) -> Option<String> { name: "".to_string(),
None icon: None,
} },
usage_to_md(current_file.path.as_str(), None),
fn resolve_external_jsdoc_module( )])
&self, })
_module: &str, .unwrap_or_default()
_symbol: Option<&str>,
) -> Option<(String, String)> {
None
} }
} }
@ -461,30 +387,10 @@ fn generate_docs_directory(
let cwd = std::env::current_dir().context("Failed to get CWD")?; let cwd = std::env::current_dir().context("Failed to get CWD")?;
let output_dir_resolved = cwd.join(&html_options.output); let output_dir_resolved = cwd.join(&html_options.output);
let internal_env = std::env::var("DENO_INTERNAL_HTML_DOCS").ok();
let href_resolver: Rc<dyn deno_doc::html::HrefResolver> = if internal_env
.as_ref()
.is_some_and(|internal_html_docs| internal_html_docs == "node")
{
Rc::new(NodeDocResolver(html_options.strip_trailing_html))
} else if internal_env
.as_ref()
.is_some_and(|internal_html_docs| internal_html_docs == "deno")
|| deno_ns.is_empty()
{
Rc::new(DenoDocResolver(html_options.strip_trailing_html))
} else {
Rc::new(DocResolver {
deno_ns,
strip_trailing_html: html_options.strip_trailing_html,
})
};
let category_docs = let category_docs =
if let Some(category_docs_path) = &html_options.category_docs_path { if let Some(category_docs_path) = &html_options.category_docs_path {
let content = std::fs::read(category_docs_path)?; let content = std::fs::read(category_docs_path)?;
Some(deno_core::serde_json::from_slice(&content)?) Some(serde_json::from_slice(&content)?)
} else { } else {
None None
}; };
@ -493,7 +399,7 @@ fn generate_docs_directory(
&html_options.symbol_redirect_map_path &html_options.symbol_redirect_map_path
{ {
let content = std::fs::read(symbol_redirect_map_path)?; let content = std::fs::read(symbol_redirect_map_path)?;
Some(deno_core::serde_json::from_slice(&content)?) Some(serde_json::from_slice(&content)?)
} else { } else {
None None
}; };
@ -502,7 +408,7 @@ fn generate_docs_directory(
&html_options.default_symbol_map_path &html_options.default_symbol_map_path
{ {
let content = std::fs::read(default_symbol_map_path)?; let content = std::fs::read(default_symbol_map_path)?;
Some(deno_core::serde_json::from_slice(&content)?) Some(serde_json::from_slice(&content)?)
} else { } else {
None None
}; };
@ -511,17 +417,59 @@ fn generate_docs_directory(
package_name: html_options.name.clone(), package_name: html_options.name.clone(),
main_entrypoint: None, main_entrypoint: None,
rewrite_map, rewrite_map,
href_resolver, href_resolver: Rc::new(DocResolver {
usage_composer: None, deno_ns,
strip_trailing_html: html_options.strip_trailing_html,
}),
usage_composer: Rc::new(DocComposer),
category_docs, category_docs,
disable_search: internal_env.is_some(), disable_search: false,
symbol_redirect_map, symbol_redirect_map,
default_symbol_map, default_symbol_map,
markdown_renderer: deno_doc::html::comrak::create_renderer(
None,
Some(Box::new(|ammonia| {
ammonia.add_allowed_classes(
"code",
&[
"language-ts",
"language-tsx",
"language-typescript",
"language-js",
"language-jsx",
"language-javascript",
"language-bash",
"language-shell",
"language-md",
"language-markdown",
"language-rs",
"language-rust",
"language-html",
"language-xml",
"language-css",
"language-json",
"language-regex",
"language-svg",
],
);
})),
None,
),
markdown_stripper: Rc::new(deno_doc::html::comrak::strip),
head_inject: Some(Rc::new(|root| {
format!(
r#"<link href="{root}{}" rel="stylesheet" /><link href="{root}prism.css" rel="stylesheet" /><script src="{root}prism.js"></script>"#,
deno_doc::html::comrak::COMRAK_STYLESHEET_FILENAME
)
})),
}; };
let files = deno_doc::html::generate(options, doc_nodes_by_url) let mut files = deno_doc::html::generate(options, doc_nodes_by_url)
.context("Failed to generate HTML documentation")?; .context("Failed to generate HTML documentation")?;
files.insert("prism.js".to_string(), PRISM_JS.to_string());
files.insert("prism.css".to_string(), PRISM_CSS.to_string());
let path = &output_dir_resolved; let path = &output_dir_resolved;
let _ = std::fs::remove_dir_all(path); let _ = std::fs::remove_dir_all(path);
std::fs::create_dir(path) std::fs::create_dir(path)

3
cli/tools/doc/prism.css Normal file
View File

@ -0,0 +1,3 @@
/* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+json+markdown+regex+rust+typescript */
code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}

15
cli/tools/doc/prism.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -447,6 +447,7 @@ impl<'a> GraphDisplayContext<'a> {
Module::Js(module) => module.maybe_cache_info.as_ref(), Module::Js(module) => module.maybe_cache_info.as_ref(),
Module::Json(module) => module.maybe_cache_info.as_ref(), Module::Json(module) => module.maybe_cache_info.as_ref(),
Module::Node(_) | Module::Npm(_) | Module::External(_) => None, Module::Node(_) | Module::Npm(_) | Module::External(_) => None,
Module::Wasm(_) => todo!("@dsherret"),
}; };
if let Some(cache_info) = maybe_cache_info { if let Some(cache_info) = maybe_cache_info {
if let Some(local) = &cache_info.local { if let Some(local) = &cache_info.local {
@ -469,6 +470,7 @@ impl<'a> GraphDisplayContext<'a> {
Module::Js(module) => module.size(), Module::Js(module) => module.size(),
Module::Json(module) => module.size(), Module::Json(module) => module.size(),
Module::Node(_) | Module::Npm(_) | Module::External(_) => 0, Module::Node(_) | Module::Npm(_) | Module::External(_) => 0,
Module::Wasm(_) => todo!("@dsherret"),
}; };
size as f64 size as f64
}) })
@ -568,6 +570,7 @@ impl<'a> GraphDisplayContext<'a> {
Module::Js(module) => Some(module.size() as u64), Module::Js(module) => Some(module.size() as u64),
Module::Json(module) => Some(module.size() as u64), Module::Json(module) => Some(module.size() as u64),
Module::Node(_) | Module::Npm(_) | Module::External(_) => None, Module::Node(_) | Module::Npm(_) | Module::External(_) => None,
Module::Wasm(_) => todo!("@dsherret"),
}, },
}; };
format!("{} {}", header_text, maybe_size_to_text(maybe_size)) format!("{} {}", header_text, maybe_size_to_text(maybe_size))
@ -670,6 +673,7 @@ impl<'a> GraphDisplayContext<'a> {
ModuleError::Missing(_, _) | ModuleError::MissingDynamic(_, _) => { ModuleError::Missing(_, _) | ModuleError::MissingDynamic(_, _) => {
self.build_error_msg(specifier, "(missing)") self.build_error_msg(specifier, "(missing)")
} }
ModuleError::WasmParseErr(_, _) => todo!("@dsherret"),
} }
} }

View File

@ -26,6 +26,7 @@ use deno_core::serde_json;
use deno_core::serde_json::json; use deno_core::serde_json::json;
use deno_core::serde_json::Value; use deno_core::serde_json::Value;
use deno_core::url::Url; use deno_core::url::Url;
use deno_graph::Module;
use deno_terminal::colors; use deno_terminal::colors;
use http_body_util::BodyExt; use http_body_util::BodyExt;
use serde::Deserialize; use serde::Deserialize;
@ -1113,6 +1114,7 @@ fn collect_excluded_module_diagnostics(
deno_graph::Module::Npm(_) deno_graph::Module::Npm(_)
| deno_graph::Module::Node(_) | deno_graph::Module::Node(_)
| deno_graph::Module::External(_) => None, | deno_graph::Module::External(_) => None,
Module::Wasm(_) => todo!("@dsherret"),
}) })
.filter(|s| s.as_str().starts_with(root.as_str())); .filter(|s| s.as_str().starts_with(root.as_str()));
for specifier in graph_specifiers { for specifier in graph_specifiers {

View File

@ -664,6 +664,7 @@ fn op_load_inner(
&mut is_cjs, &mut is_cjs,
)?)) )?))
} }
Module::Wasm(_) => todo!("@dsherret"),
} }
} else if let Some(npm) = state } else if let Some(npm) = state
.maybe_npm .maybe_npm
@ -928,6 +929,7 @@ fn resolve_graph_specifier_types(
})) }))
} }
Some(Module::Node(_)) | None => Ok(None), Some(Module::Node(_)) | None => Ok(None),
Some(Module::Wasm(_)) => todo!("@dsherret"),
} }
} }

View File

@ -1 +1 @@
Written 12 files to "./docs/" Written 15 files to "./docs/"

View File

@ -31,6 +31,8 @@ export async function checkCopyright() {
":!:.github/mtime_cache/action.js", ":!:.github/mtime_cache/action.js",
":!:cli/bench/testdata/**", ":!:cli/bench/testdata/**",
":!:cli/tools/bench/mitata.rs", ":!:cli/tools/bench/mitata.rs",
":!:cli/tools/doc/prism.css",
":!:cli/tools/doc/prism.js",
":!:cli/tools/init/templates/**", ":!:cli/tools/init/templates/**",
":!:cli/tsc/*typescript.js", ":!:cli/tsc/*typescript.js",
":!:cli/tsc/compiler.d.ts", ":!:cli/tsc/compiler.d.ts",

View File

@ -51,6 +51,8 @@ async function dlint() {
":!:cli/bench/testdata/express-router.js", ":!:cli/bench/testdata/express-router.js",
":!:cli/bench/testdata/react-dom.js", ":!:cli/bench/testdata/react-dom.js",
":!:cli/compilers/wasm_wrap.js", ":!:cli/compilers/wasm_wrap.js",
":!:cli/tools/doc/prism.css",
":!:cli/tools/doc/prism.js",
":!:cli/tsc/dts/**", ":!:cli/tsc/dts/**",
":!:cli/tsc/*typescript.js", ":!:cli/tsc/*typescript.js",
":!:cli/tsc/compiler.d.ts", ":!:cli/tsc/compiler.d.ts",