1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-01 16:51:13 -05:00

chore: update deno_doc to 0.85.0 (#21678)

This commit is contained in:
Leo Kettmeir 2023-12-30 01:04:50 +01:00 committed by Bartek Iwańczuk
parent a267225a17
commit 491f8e9731
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
3 changed files with 198 additions and 25 deletions

138
Cargo.lock generated
View file

@ -645,9 +645,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "comrak"
version = "0.19.0"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82c995deda3bfdebd07d0e2af79e9da13e4b1be652b21a746f3f5b24bf0a49ef"
checksum = "9f18e72341e6cdc7489cffb76f993812a14a906db54dedb020044ccc211dcaae"
dependencies = [
"derive_builder",
"entities",
@ -1209,9 +1209,9 @@ dependencies = [
[[package]]
name = "deno_doc"
version = "0.75.1"
version = "0.85.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cc0fc1ccb5da952f569baf067364a281bbb551180b96aca5d37b4bb5f28410a"
checksum = "83b6320fb6467aa87c64e9ab09d07186f771f80f74b110e35e9063a9d6a27a30"
dependencies = [
"anyhow",
"cfg-if",
@ -1219,6 +1219,7 @@ dependencies = [
"deno_ast",
"deno_graph",
"futures",
"handlebars",
"html-escape",
"import_map",
"indexmap 2.1.0",
@ -1226,8 +1227,8 @@ dependencies = [
"regex",
"serde",
"serde_json",
"syntect",
"termcolor",
"tinytemplate",
]
[[package]]
@ -2820,6 +2821,21 @@ dependencies = [
"serde",
]
[[package]]
name = "handlebars"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225"
dependencies = [
"heck",
"log",
"pest",
"pest_derive",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@ -3969,6 +3985,28 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "opaque-debug"
version = "0.3.0"
@ -4153,6 +4191,51 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]]
name = "pest"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5"
dependencies = [
"memchr",
"thiserror",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]]
name = "pest_meta"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6"
dependencies = [
"once_cell",
"pest",
"sha2",
]
[[package]]
name = "petgraph"
version = "0.6.4"
@ -4620,7 +4703,7 @@ dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
"regex-syntax 0.8.2",
]
[[package]]
@ -4631,9 +4714,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"regex-syntax 0.8.2",
]
[[package]]
name = "regex-syntax"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "regex-syntax"
version = "0.8.2"
@ -5907,6 +5996,25 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "syntect"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91"
dependencies = [
"bincode",
"bitflags 1.3.2",
"flate2",
"fnv",
"once_cell",
"onig",
"regex-syntax 0.7.5",
"serde",
"serde_json",
"thiserror",
"walkdir",
]
[[package]]
name = "tar"
version = "0.4.40"
@ -6068,16 +6176,6 @@ dependencies = [
"time-core",
]
[[package]]
name = "tinytemplate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "tinyvec"
version = "1.6.0"
@ -6401,6 +6499,12 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "ucd-trie"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "unic-char-property"
version = "0.9.0"

View file

@ -60,7 +60,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
deno_cache_dir = "=0.6.1"
deno_config = "=0.6.5"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "=0.75.1", features = ["html"] }
deno_doc = { version = "=0.85.0", features = ["html"] }
deno_emit = "=0.32.0"
deno_graph = "=0.62.2"
deno_lint = { version = "=0.52.2", features = ["docs"] }

View file

@ -153,8 +153,26 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
}
};
if let Some(html_options) = doc_flags.html {
generate_docs_directory(&doc_nodes_by_url, html_options)
if let Some(html_options) = &doc_flags.html {
let deno_ns = if doc_flags.source_files != DocSourceFileFlag::Builtin {
let deno_ns = generate_doc_nodes_for_builtin_types(
doc_flags.clone(),
cli_options,
capturing_parser,
&analyzer,
)
.await?;
let (_, deno_ns) = deno_ns.first().unwrap();
let deno_ns_symbols =
deno_doc::html::compute_namespaced_symbols(deno_ns, &[]);
Some(deno_ns_symbols)
} else {
None
};
generate_docs_directory(&doc_nodes_by_url, html_options, deno_ns)
.boxed_local()
.await
} else {
@ -178,19 +196,70 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
}
}
struct DocResolver {}
impl deno_doc::html::HrefResolver for DocResolver {
fn resolve_global_symbol(&self, symbol: &[String], _context: &str) -> String {
format!(
"https://deno.land/api@{}?s={}",
env!("CARGO_PKG_VERSION"),
symbol.join(".")
)
}
fn resolve_import_href(
&self,
symbol: &[String],
src: &str,
) -> Option<String> {
let mut url = ModuleSpecifier::parse(src).ok()?;
if url.domain() == Some("deno.land") {
url.set_query(Some(&format!("s={}", symbol.join("."))));
return Some(url.to_string());
}
None
}
fn resolve_usage(
&self,
_current_specifier: &ModuleSpecifier,
current_file: &str,
) -> String {
current_file.to_string()
}
fn resolve_source(&self, location: &deno_doc::Location) -> String {
location.filename.clone()
}
}
async fn generate_docs_directory(
doc_nodes_by_url: &IndexMap<ModuleSpecifier, Vec<doc::DocNode>>,
html_options: DocHtmlFlag,
html_options: &DocHtmlFlag,
deno_ns: Option<std::collections::HashSet<Vec<String>>>,
) -> Result<(), AnyError> {
let cwd = std::env::current_dir().context("Failed to get CWD")?;
let output_dir_resolved = cwd.join(&html_options.output);
let options = deno_doc::html::GenerateOptions {
package_name: Some(html_options.name),
package_name: Some(html_options.name.to_owned()),
main_entrypoint: None,
global_symbols: Default::default(),
global_symbol_href_resolver: Rc::new(|_, _| String::new()),
url_resolver: Rc::new(deno_doc::html::default_url_resolver),
global_symbols: deno_doc::html::NamespacedGlobalSymbols::new(
deno_ns
.map(|deno_ns| {
deno_ns
.into_iter()
.map(|symbol| (symbol, "deno".to_string()))
.collect()
})
.unwrap_or_default(),
),
rewrite_map: None,
hide_module_doc_title: false,
href_resolver: Rc::new(DocResolver {}),
sidebar_flatten_namespaces: false,
};
let files = deno_doc::html::generate(options, doc_nodes_by_url)