mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
fix(tools/doc): HTML resolve main entrypoint from config file (#27103)
Fixes #26901
This commit is contained in:
parent
927352bd4e
commit
7400181ecb
6 changed files with 46 additions and 10 deletions
|
@ -209,10 +209,14 @@ pub async fn doc(
|
|||
Default::default()
|
||||
};
|
||||
|
||||
let mut main_entrypoint = None;
|
||||
|
||||
let rewrite_map =
|
||||
if let Some(config_file) = cli_options.start_dir.maybe_deno_json() {
|
||||
let config = config_file.to_exports_config()?;
|
||||
|
||||
main_entrypoint = config.get_resolved(".").ok().flatten();
|
||||
|
||||
let rewrite_map = config
|
||||
.clone()
|
||||
.into_map()
|
||||
|
@ -240,6 +244,7 @@ pub async fn doc(
|
|||
html_options,
|
||||
deno_ns,
|
||||
rewrite_map,
|
||||
main_entrypoint,
|
||||
)
|
||||
} else {
|
||||
let modules_len = doc_nodes_by_url.len();
|
||||
|
@ -383,6 +388,7 @@ fn generate_docs_directory(
|
|||
html_options: &DocHtmlFlag,
|
||||
deno_ns: std::collections::HashMap<Vec<String>, Option<Rc<ShortPath>>>,
|
||||
rewrite_map: Option<IndexMap<ModuleSpecifier, String>>,
|
||||
main_entrypoint: Option<ModuleSpecifier>,
|
||||
) -> Result<(), AnyError> {
|
||||
let cwd = std::env::current_dir().context("Failed to get CWD")?;
|
||||
let output_dir_resolved = cwd.join(&html_options.output);
|
||||
|
@ -415,7 +421,7 @@ fn generate_docs_directory(
|
|||
|
||||
let options = deno_doc::html::GenerateOptions {
|
||||
package_name: html_options.name.clone(),
|
||||
main_entrypoint: None,
|
||||
main_entrypoint,
|
||||
rewrite_map,
|
||||
href_resolver: Rc::new(DocResolver {
|
||||
deno_ns,
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"args": [
|
||||
"doc",
|
||||
"--html",
|
||||
"--name=MyLib",
|
||||
"--output=temp_dir_path_here",
|
||||
"referenced_private_types_fixed.ts"
|
||||
],
|
||||
"output": "[WILDCARD]",
|
||||
"exitCode": 0
|
||||
"steps": [
|
||||
{
|
||||
"args": [
|
||||
"doc",
|
||||
"--html",
|
||||
"--name=MyLib",
|
||||
"a.ts",
|
||||
"b.ts"
|
||||
],
|
||||
"output": "Written 23 files to \"./docs/\"\n",
|
||||
"exitCode": 0
|
||||
},
|
||||
{
|
||||
"args": "run --allow-read check_file.ts",
|
||||
"output": "",
|
||||
"exitCode": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
11
tests/specs/doc/html/b.ts
Normal file
11
tests/specs/doc/html/b.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/** Doc comment */
|
||||
export interface MyInterface2 {
|
||||
/** Doc comment */
|
||||
prop?: string;
|
||||
}
|
||||
|
||||
/** Doc comment */
|
||||
export class MyClass2 {
|
||||
/** Doc comment */
|
||||
prop: MyInterface2 = {};
|
||||
}
|
5
tests/specs/doc/html/check_file.ts
Normal file
5
tests/specs/doc/html/check_file.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
const content = Deno.readTextFileSync("./docs/index.html");
|
||||
|
||||
if (content.includes("..")) {
|
||||
throw new Error();
|
||||
}
|
5
tests/specs/doc/html/deno.json
Normal file
5
tests/specs/doc/html/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"exports": {
|
||||
".": "./a.ts"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue