diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 197596167fecea..9a24e458ac9e9b 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -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, Option>>, rewrite_map: Option>, + main_entrypoint: Option, ) -> 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, diff --git a/tests/specs/doc/html/__test__.jsonc b/tests/specs/doc/html/__test__.jsonc index 5114127cd61a09..78ced63744e82a 100644 --- a/tests/specs/doc/html/__test__.jsonc +++ b/tests/specs/doc/html/__test__.jsonc @@ -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 + } + ] } diff --git a/tests/specs/doc/html/referenced_private_types_fixed.ts b/tests/specs/doc/html/a.ts similarity index 100% rename from tests/specs/doc/html/referenced_private_types_fixed.ts rename to tests/specs/doc/html/a.ts diff --git a/tests/specs/doc/html/b.ts b/tests/specs/doc/html/b.ts new file mode 100644 index 00000000000000..bb385369923e67 --- /dev/null +++ b/tests/specs/doc/html/b.ts @@ -0,0 +1,11 @@ +/** Doc comment */ +export interface MyInterface2 { + /** Doc comment */ + prop?: string; +} + +/** Doc comment */ +export class MyClass2 { + /** Doc comment */ + prop: MyInterface2 = {}; +} diff --git a/tests/specs/doc/html/check_file.ts b/tests/specs/doc/html/check_file.ts new file mode 100644 index 00000000000000..7d2fdeff5f6256 --- /dev/null +++ b/tests/specs/doc/html/check_file.ts @@ -0,0 +1,5 @@ +const content = Deno.readTextFileSync("./docs/index.html"); + +if (content.includes("..")) { + throw new Error(); +} diff --git a/tests/specs/doc/html/deno.json b/tests/specs/doc/html/deno.json new file mode 100644 index 00000000000000..b466b28003a728 --- /dev/null +++ b/tests/specs/doc/html/deno.json @@ -0,0 +1,5 @@ +{ + "exports": { + ".": "./a.ts" + } +}