├── .clippy.toml ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .rustfmt.toml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── benches ├── doc_parser.rs └── fixtures │ └── deno.d.ts ├── build_css.ts ├── deno.json ├── deno.lock ├── examples └── ddoc │ └── main.rs ├── js ├── README.md ├── allow_leak_test.ts ├── deno.json ├── html_types.d.ts ├── mod.ts ├── test.ts └── types.d.ts ├── lib ├── Cargo.toml └── lib.rs ├── rust-toolchain.toml ├── src ├── class.rs ├── decorators.rs ├── diagnostics.rs ├── display.rs ├── enum.rs ├── function.rs ├── html │ ├── comrak.rs │ ├── jsdoc.rs │ ├── mod.rs │ ├── pages.rs │ ├── parameters.rs │ ├── partition.rs │ ├── render_context.rs │ ├── search.rs │ ├── symbols │ │ ├── class.rs │ │ ├── enum.rs │ │ ├── function.rs │ │ ├── interface.rs │ │ ├── mod.rs │ │ ├── namespace.rs │ │ ├── type_alias.rs │ │ └── variable.rs │ ├── templates │ │ ├── anchor.hbs │ │ ├── breadcrumbs.hbs │ │ ├── category_panel.hbs │ │ ├── comrak.css │ │ ├── comrak.gen.css │ │ ├── deprecated.hbs │ │ ├── doc_block_subtitle_class.hbs │ │ ├── doc_block_subtitle_interface.hbs │ │ ├── doc_entry.hbs │ │ ├── doc_node_kind_icon.hbs │ │ ├── example.hbs │ │ ├── function.hbs │ │ ├── icons │ │ │ ├── arrow.svg │ │ │ ├── check.svg │ │ │ ├── copy.svg │ │ │ ├── link.svg │ │ │ ├── menu.svg │ │ │ ├── moon.svg │ │ │ ├── source.svg │ │ │ └── sun.svg │ │ ├── index_signature.hbs │ │ ├── module_doc.hbs │ │ ├── namespace_section.hbs │ │ ├── pages │ │ │ ├── all_symbols.hbs │ │ │ ├── darkmode_toggle.js │ │ │ ├── fuse.js │ │ │ ├── html_head.hbs │ │ │ ├── index.hbs │ │ │ ├── page.css │ │ │ ├── page.gen.css │ │ │ ├── redirect.hbs │ │ │ ├── reset.css │ │ │ ├── reset.gen.css │ │ │ ├── search.js │ │ │ ├── search_results.hbs │ │ │ ├── symbol.hbs │ │ │ ├── tailwind.config.ts │ │ │ └── top_nav.hbs │ │ ├── script.js │ │ ├── section.hbs │ │ ├── see.hbs │ │ ├── source_button.hbs │ │ ├── styles.css │ │ ├── styles.gen.css │ │ ├── symbol_content.hbs │ │ ├── symbol_group.hbs │ │ ├── tag.hbs │ │ ├── toc.hbs │ │ ├── usages.hbs │ │ └── usages_large.hbs │ ├── types.rs │ ├── usage.rs │ └── util.rs ├── interface.rs ├── js_doc.rs ├── lib.rs ├── node.rs ├── params.rs ├── parser.rs ├── printer.rs ├── tests.rs ├── ts_type.rs ├── ts_type_param.rs ├── type_alias.rs ├── util │ ├── graph.rs │ ├── mod.rs │ ├── swc.rs │ └── symbol.rs ├── variable.rs └── visibility.rs ├── tailwind.config.ts └── tests ├── helpers └── mod.rs ├── html_test.rs ├── snapshots ├── html_test__html_doc_dts-10.snap ├── html_test__html_doc_dts-11.snap ├── html_test__html_doc_dts-12.snap ├── html_test__html_doc_dts-13.snap ├── html_test__html_doc_dts-14.snap ├── html_test__html_doc_dts-2.snap ├── html_test__html_doc_dts-3.snap ├── html_test__html_doc_dts-4.snap ├── html_test__html_doc_dts-5.snap ├── html_test__html_doc_dts-6.snap ├── html_test__html_doc_dts-7.snap ├── html_test__html_doc_dts-8.snap ├── html_test__html_doc_dts-9.snap ├── html_test__html_doc_dts.snap ├── html_test__html_doc_files-10.snap ├── html_test__html_doc_files-11.snap ├── html_test__html_doc_files-12.snap ├── html_test__html_doc_files-2.snap ├── html_test__html_doc_files-3.snap ├── html_test__html_doc_files-4.snap ├── html_test__html_doc_files-5.snap ├── html_test__html_doc_files-6.snap ├── html_test__html_doc_files-7.snap ├── html_test__html_doc_files-8.snap ├── html_test__html_doc_files-9.snap ├── html_test__html_doc_files.snap ├── html_test__html_doc_files_multiple-10.snap ├── html_test__html_doc_files_multiple-11.snap ├── html_test__html_doc_files_multiple-12.snap ├── html_test__html_doc_files_multiple-13.snap ├── html_test__html_doc_files_multiple-14.snap ├── html_test__html_doc_files_multiple-15.snap ├── html_test__html_doc_files_multiple-16.snap ├── html_test__html_doc_files_multiple-17.snap ├── html_test__html_doc_files_multiple-18.snap ├── html_test__html_doc_files_multiple-19.snap ├── html_test__html_doc_files_multiple-2.snap ├── html_test__html_doc_files_multiple-20.snap ├── html_test__html_doc_files_multiple-21.snap ├── html_test__html_doc_files_multiple-22.snap ├── html_test__html_doc_files_multiple-23.snap ├── html_test__html_doc_files_multiple-24.snap ├── html_test__html_doc_files_multiple-25.snap ├── html_test__html_doc_files_multiple-26.snap ├── html_test__html_doc_files_multiple-27.snap ├── html_test__html_doc_files_multiple-28.snap ├── html_test__html_doc_files_multiple-29.snap ├── html_test__html_doc_files_multiple-3.snap ├── html_test__html_doc_files_multiple-30.snap ├── html_test__html_doc_files_multiple-31.snap ├── html_test__html_doc_files_multiple-32.snap ├── html_test__html_doc_files_multiple-33.snap ├── html_test__html_doc_files_multiple-34.snap ├── html_test__html_doc_files_multiple-35.snap ├── html_test__html_doc_files_multiple-36.snap ├── html_test__html_doc_files_multiple-37.snap ├── html_test__html_doc_files_multiple-38.snap ├── html_test__html_doc_files_multiple-39.snap ├── html_test__html_doc_files_multiple-4.snap ├── html_test__html_doc_files_multiple-40.snap ├── html_test__html_doc_files_multiple-41.snap ├── html_test__html_doc_files_multiple-42.snap ├── html_test__html_doc_files_multiple-43.snap ├── html_test__html_doc_files_multiple-44.snap ├── html_test__html_doc_files_multiple-45.snap ├── html_test__html_doc_files_multiple-46.snap ├── html_test__html_doc_files_multiple-47.snap ├── html_test__html_doc_files_multiple-48.snap ├── html_test__html_doc_files_multiple-49.snap ├── html_test__html_doc_files_multiple-5.snap ├── html_test__html_doc_files_multiple-50.snap ├── html_test__html_doc_files_multiple-51.snap ├── html_test__html_doc_files_multiple-52.snap ├── html_test__html_doc_files_multiple-53.snap ├── html_test__html_doc_files_multiple-54.snap ├── html_test__html_doc_files_multiple-55.snap ├── html_test__html_doc_files_multiple-56.snap ├── html_test__html_doc_files_multiple-57.snap ├── html_test__html_doc_files_multiple-58.snap ├── html_test__html_doc_files_multiple-59.snap ├── html_test__html_doc_files_multiple-6.snap ├── html_test__html_doc_files_multiple-60.snap ├── html_test__html_doc_files_multiple-61.snap ├── html_test__html_doc_files_multiple-62.snap ├── html_test__html_doc_files_multiple-63.snap ├── html_test__html_doc_files_multiple-64.snap ├── html_test__html_doc_files_multiple-65.snap ├── html_test__html_doc_files_multiple-66.snap ├── html_test__html_doc_files_multiple-67.snap ├── html_test__html_doc_files_multiple-68.snap ├── html_test__html_doc_files_multiple-69.snap ├── html_test__html_doc_files_multiple-7.snap ├── html_test__html_doc_files_multiple-70.snap ├── html_test__html_doc_files_multiple-71.snap ├── html_test__html_doc_files_multiple-72.snap ├── html_test__html_doc_files_multiple-73.snap ├── html_test__html_doc_files_multiple-8.snap ├── html_test__html_doc_files_multiple-9.snap ├── html_test__html_doc_files_multiple.snap ├── html_test__html_doc_files_rewrite-10.snap ├── html_test__html_doc_files_rewrite-11.snap ├── html_test__html_doc_files_rewrite-12.snap ├── html_test__html_doc_files_rewrite-13.snap ├── html_test__html_doc_files_rewrite-14.snap ├── html_test__html_doc_files_rewrite-15.snap ├── html_test__html_doc_files_rewrite-16.snap ├── html_test__html_doc_files_rewrite-17.snap ├── html_test__html_doc_files_rewrite-18.snap ├── html_test__html_doc_files_rewrite-19.snap ├── html_test__html_doc_files_rewrite-2.snap ├── html_test__html_doc_files_rewrite-20.snap ├── html_test__html_doc_files_rewrite-21.snap ├── html_test__html_doc_files_rewrite-22.snap ├── html_test__html_doc_files_rewrite-23.snap ├── html_test__html_doc_files_rewrite-24.snap ├── html_test__html_doc_files_rewrite-25.snap ├── html_test__html_doc_files_rewrite-26.snap ├── html_test__html_doc_files_rewrite-27.snap ├── html_test__html_doc_files_rewrite-28.snap ├── html_test__html_doc_files_rewrite-29.snap ├── html_test__html_doc_files_rewrite-3.snap ├── html_test__html_doc_files_rewrite-30.snap ├── html_test__html_doc_files_rewrite-31.snap ├── html_test__html_doc_files_rewrite-32.snap ├── html_test__html_doc_files_rewrite-33.snap ├── html_test__html_doc_files_rewrite-34.snap ├── html_test__html_doc_files_rewrite-35.snap ├── html_test__html_doc_files_rewrite-36.snap ├── html_test__html_doc_files_rewrite-37.snap ├── html_test__html_doc_files_rewrite-38.snap ├── html_test__html_doc_files_rewrite-39.snap ├── html_test__html_doc_files_rewrite-4.snap ├── html_test__html_doc_files_rewrite-40.snap ├── html_test__html_doc_files_rewrite-41.snap ├── html_test__html_doc_files_rewrite-42.snap ├── html_test__html_doc_files_rewrite-43.snap ├── html_test__html_doc_files_rewrite-44.snap ├── html_test__html_doc_files_rewrite-45.snap ├── html_test__html_doc_files_rewrite-46.snap ├── html_test__html_doc_files_rewrite-47.snap ├── html_test__html_doc_files_rewrite-48.snap ├── html_test__html_doc_files_rewrite-49.snap ├── html_test__html_doc_files_rewrite-5.snap ├── html_test__html_doc_files_rewrite-50.snap ├── html_test__html_doc_files_rewrite-51.snap ├── html_test__html_doc_files_rewrite-52.snap ├── html_test__html_doc_files_rewrite-53.snap ├── html_test__html_doc_files_rewrite-54.snap ├── html_test__html_doc_files_rewrite-55.snap ├── html_test__html_doc_files_rewrite-56.snap ├── html_test__html_doc_files_rewrite-57.snap ├── html_test__html_doc_files_rewrite-58.snap ├── html_test__html_doc_files_rewrite-59.snap ├── html_test__html_doc_files_rewrite-6.snap ├── html_test__html_doc_files_rewrite-60.snap ├── html_test__html_doc_files_rewrite-61.snap ├── html_test__html_doc_files_rewrite-62.snap ├── html_test__html_doc_files_rewrite-63.snap ├── html_test__html_doc_files_rewrite-64.snap ├── html_test__html_doc_files_rewrite-65.snap ├── html_test__html_doc_files_rewrite-66.snap ├── html_test__html_doc_files_rewrite-67.snap ├── html_test__html_doc_files_rewrite-68.snap ├── html_test__html_doc_files_rewrite-69.snap ├── html_test__html_doc_files_rewrite-7.snap ├── html_test__html_doc_files_rewrite-70.snap ├── html_test__html_doc_files_rewrite-8.snap ├── html_test__html_doc_files_rewrite-9.snap ├── html_test__html_doc_files_rewrite.snap ├── html_test__html_doc_files_single-10.snap ├── html_test__html_doc_files_single-11.snap ├── html_test__html_doc_files_single-12.snap ├── html_test__html_doc_files_single-13.snap ├── html_test__html_doc_files_single-2.snap ├── html_test__html_doc_files_single-3.snap ├── html_test__html_doc_files_single-4.snap ├── html_test__html_doc_files_single-5.snap ├── html_test__html_doc_files_single-6.snap ├── html_test__html_doc_files_single-7.snap ├── html_test__html_doc_files_single-8.snap ├── html_test__html_doc_files_single-9.snap ├── html_test__html_doc_files_single.snap ├── html_test__module_doc.snap ├── html_test__symbol_group.snap └── html_test__symbol_search.snap ├── specs ├── Jsdoc.txt ├── Jsdoc_codeblock.txt ├── Jsdoc_for_source_starts_with_shebang.txt ├── Jsdoc_tags_codeblock.txt ├── Overloads.txt ├── abstract_class.txt ├── abstract_class_abstract_method.txt ├── class_async_method.txt ├── class_constructor.txt ├── class_declaration.txt ├── class_decorators.txt ├── class_details.txt ├── class_details_all_with_private.txt ├── class_details_only_non_private_without_private.txt ├── class_extends.txt ├── class_extends_implements.txt ├── class_generic_extends_implements.txt ├── class_getter_and_setter.txt ├── class_implements.txt ├── class_implements2.txt ├── class_index_signature.txt ├── class_method.txt ├── class_method_overloads.txt ├── class_override_prop_method.txt ├── class_private_property.txt ├── class_property.txt ├── class_readonly_index_signature.txt ├── class_readonly_property.txt ├── class_static_property.txt ├── const_declaration.txt ├── ctor_overloads.txt ├── declare_namespace.txt ├── declare_namespace_ignore.txt ├── decorators_jsdoc.txt ├── default_exports_declared_earlier.txt ├── destructuring_assignment_array.txt ├── destructuring_assignment_object.txt ├── destructuring_assignment_object_assignment.txt ├── doc_printer_unsupported_tag.txt ├── enum_declaration.txt ├── enum_member.txt ├── expando_props │ └── basic.txt ├── export_class.txt ├── export_class_ctor_properties.txt ├── export_class_decorators.txt ├── export_class_ignore.txt ├── export_class_object_extends.txt ├── export_const_basic.txt ├── export_const_destructured.txt ├── export_declaration_merged_namespace.txt ├── export_default_class.txt ├── export_default_expr.txt ├── export_default_fn.txt ├── export_default_interface.txt ├── export_enum.txt ├── export_fn.txt ├── export_fn2.txt ├── export_interface.txt ├── export_interface2.txt ├── export_interface_accessors.txt ├── export_let.txt ├── export_namespace.txt ├── export_namespace_enum_same_name.txt ├── export_private.txt ├── export_type_alias.txt ├── export_type_alias_literal.txt ├── exports_all_with_private.txt ├── exports_declared_earlier.txt ├── function_array_deconstruction.txt ├── function_async.txt ├── function_async_generator.txt ├── function_declaration.txt ├── function_generator.txt ├── function_generic.txt ├── function_object_deconstruction.txt ├── function_overloads.txt ├── generic_instantiated_with_tuple_type.txt ├── import_equals.txt ├── import_types.txt ├── indented_with_tabs.txt ├── infer_function_assignment.txt ├── infer_object_literal.txt ├── infer_object_literal_satifies.txt ├── infer_simple_ts_arr_types.txt ├── infer_simple_ts_types.txt ├── infer_ts_types.txt ├── infer_types.txt ├── infer_variable.txt ├── interface_construct.txt ├── interface_declaration.txt ├── interface_declaration_with_non_ascii_characters.txt ├── interface_extends.txt ├── interface_extends2.txt ├── interface_generic.txt ├── interface_generic_extends.txt ├── interface_index_signature.txt ├── interface_method.txt ├── interface_number_literal_property.txt ├── interface_property.txt ├── interface_readonly_index_signature.txt ├── interface_string_literal_property.txt ├── internal_tag.txt ├── jsdoc_tags.txt ├── mapped_types.txt ├── module_docs.txt ├── module_docs_ignore.txt ├── module_docs_ignore_no_module_tag.txt ├── namespace_declaration.txt ├── namespace_details.txt ├── namespace_exports_self.txt ├── namespace_fn_overloads.txt ├── namespace_reexport_member.txt ├── no_ambient_in_module.txt ├── non_implemented_renamed_exports_declared_earlier.txt ├── optional_return_type.txt ├── private_type_class_property.txt ├── private_type_ignored_class_not_namespace.txt ├── private_type_implementation_signature.txt ├── private_type_in_namespace.txt ├── private_type_other_module.txt ├── private_type_private_member.txt ├── private_type_re_export_referencing.txt ├── private_type_referenced_from_class_member.txt ├── private_type_referenced_from_namespace.txt ├── re_export_all.txt ├── re_export_clashes_private_type_bug.txt ├── reexport_deep.txt ├── reexport_existing_export.txt ├── remote_module_re_export_no_diagnostics.txt ├── structured_jsdoc.txt ├── ts_lit_types.txt ├── ts_template_with_args.txt ├── ts_type_assertion.txt ├── ts_type_predicate1.txt ├── ts_type_predicate2.txt ├── ts_type_predicate3.txt ├── ts_user_defined_type_guards.txt ├── type_alias.txt ├── type_alias_infer_type.txt ├── type_generic_alias.txt ├── type_import_type.txt ├── type_literal_declaration.txt ├── type_literal_index_signature.txt ├── type_literal_mapped_type.txt └── type_literal_readonly_index_signature.txt ├── specs_test.rs └── testdata ├── dts └── a.d.ts ├── multiple ├── _d.ts ├── a.ts ├── b.ts └── c.ts └── single └── a.ts /.clippy.toml: -------------------------------------------------------------------------------- 1 | # Prefer using `SourcePos` from deno_ast because it abstracts 2 | # away swc's non-zero-indexed based positioning 3 | disallowed-methods = [ 4 | "swc_common::Spanned::span", 5 | ] 6 | disallowed-types = [ 7 | "swc_common::BytePos", 8 | "swc_common::Span", 9 | "swc_common::Spanned", 10 | ] 11 | -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/rust/.devcontainer/base.Dockerfile 2 | 3 | FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1 4 | 5 | ENV DENO_INSTALL=/deno 6 | RUN mkdir -p /deno \ 7 | && curl -fsSL https://deno.land/x/install/install.sh | sh \ 8 | && chown -R vscode /deno 9 | 10 | ENV PATH=${DENO_INSTALL}/bin:${PATH} \ 11 | DENO_DIR=${DENO_INSTALL}/.cache/deno 12 | 13 | RUN rustup target add wasm32-unknown-unknown 14 | RUN cargo install -f wasm-bindgen-cli 15 | 16 | RUN chown -R vscode /usr/local/cargo 17 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deno_doc", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--cap-add=SYS_PTRACE", 8 | "--security-opt", 9 | "seccomp=unconfined" 10 | ], 11 | // Set *default* container specific settings.json values on container create. 12 | "settings": { 13 | "lldb.executable": "/usr/bin/lldb", 14 | "files.watcherExclude": { 15 | "**/target/**": true 16 | } 17 | }, 18 | // Add the IDs of extensions you want installed when the container is created. 19 | "extensions": [ 20 | "matklad.rust-analyzer", 21 | "vadimcn.vscode-lldb", 22 | "serayuzgur.crates", 23 | "mutantdino.resourcemonitor", 24 | "tamasfe.even-better-toml", 25 | "denoland.vscode-deno" 26 | ], 27 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 28 | // "forwardPorts": [], 29 | // Use 'postCreateCommand' to run commands after the container is created. 30 | // "postCreateCommand": "rustc --version", 31 | // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 32 | "remoteUser": "vscode" 33 | } 34 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | indent_style = space 7 | indent_size = 2 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Use Unix line endings in all text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | releaseKind: 7 | description: "Kind of release" 8 | default: "minor" 9 | type: choice 10 | options: 11 | - patch 12 | - minor 13 | required: true 14 | 15 | jobs: 16 | rust: 17 | name: release 18 | runs-on: ubuntu-latest 19 | timeout-minutes: 30 20 | 21 | steps: 22 | - name: Clone repository 23 | uses: actions/checkout@v4 24 | with: 25 | token: ${{ secrets.DENOBOT_PAT }} 26 | 27 | - uses: denoland/setup-deno@v2 28 | - uses: dsherret/rust-toolchain-file@v1 29 | 30 | - name: Tag and release 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.DENOBOT_PAT }} 33 | GH_WORKFLOW_ACTOR: ${{ github.actor }} 34 | run: | 35 | git config user.email "denobot@users.noreply.github.com" 36 | git config user.name "denobot" 37 | deno run -A https://raw.githubusercontent.com/denoland/automation/0.14.1/tasks/publish_release.ts --${{github.event.inputs.releaseKind}} deno_doc 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /js/deno_doc_wasm_bg.wasm 3 | /js/deno_doc_wasm.generated.d.ts 4 | /js/deno_doc_wasm.generated.js 5 | /js/LICENSE 6 | .vscode 7 | 8 | # IDE 9 | /.idea 10 | 11 | # OS 12 | .DS_Store 13 | 14 | /generated_docs/ -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 80 2 | tab_spaces = 2 3 | edition = "2021" 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deno_doc" 3 | version = "0.177.0" 4 | edition = "2021" 5 | description = "doc generation for deno" 6 | authors = ["the Deno authors"] 7 | license = "MIT" 8 | repository = "https://github.com/denoland/deno_doc" 9 | 10 | [workspace] 11 | members = ["lib"] 12 | 13 | [workspace.dependencies] 14 | deno_graph = { version = "0.94.0", default-features = false, features = ["symbols"] } 15 | deno_ast = { version = "0.48.0" } 16 | import_map = "0.22.0" 17 | serde = { version = "1.0.204", features = ["derive"] } 18 | 19 | [lib] 20 | crate-type = ["cdylib", "rlib"] 21 | name = "deno_doc" 22 | 23 | [[example]] 24 | name = "ddoc" 25 | required-features = ["comrak"] 26 | 27 | [dependencies] 28 | anyhow = "1.0.86" 29 | cfg-if = "1.0.0" 30 | deno_ast.workspace = true 31 | deno_graph.workspace = true 32 | deno_terminal = "0.2.0" 33 | indexmap = "2.3.0" 34 | import_map.workspace = true 35 | lazy_static = "1.5.0" 36 | regex = "1.10.6" 37 | serde.workspace = true 38 | serde_json = { version = "1.0.122", features = ["preserve_order"] } 39 | termcolor = "1.4.1" 40 | itoa = "1.0.14" 41 | deno_path_util = "0.4.0" 42 | 43 | html-escape = { version = "0.2.13" } 44 | handlebars = { version = "6.1", features = ["string_helpers"] } 45 | comrak = { version = "0.29.0", optional = true, default-features = false } 46 | 47 | [dev-dependencies] 48 | anyhow = { version = "1.0.86" } 49 | clap = "2.34.0" 50 | console_static_text = "0.8.2" 51 | criterion = { version = "0.4.0", features = ["async_futures", "html_reports"] } 52 | file_test_runner = "0.7.2" 53 | futures = "0.3.30" 54 | tokio = { version = "1.39.2", features = ["full"] } 55 | pretty_assertions = "1.4.0" 56 | insta = { version = "1.39.0", features = ["json"] } 57 | 58 | [target.'cfg(target_arch = "wasm32")'.dependencies] 59 | url = "2.4.1" 60 | percent-encoding = "2.3.1" 61 | wasm-bindgen = "0.2.92" 62 | js-sys = "0.3.69" 63 | serde-wasm-bindgen = "=0.5.0" 64 | 65 | [features] 66 | default = ["rust", "comrak"] 67 | rust = [] 68 | 69 | [[test]] 70 | name = "specs" 71 | path = "tests/specs_test.rs" 72 | harness = false 73 | 74 | [profile.release] 75 | codegen-units = 1 76 | incremental = true 77 | lto = true 78 | opt-level = "s" 79 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2024 the Deno authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /benches/doc_parser.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. 2 | 3 | use criterion::async_executor::FuturesExecutor; 4 | use criterion::criterion_group; 5 | use criterion::criterion_main; 6 | use criterion::Criterion; 7 | 8 | use deno_doc::DocNode; 9 | use deno_doc::DocParser; 10 | use deno_doc::DocParserOptions; 11 | use deno_graph::source::MemoryLoader; 12 | use deno_graph::source::Source; 13 | use deno_graph::BuildOptions; 14 | use deno_graph::CapturingModuleAnalyzer; 15 | use deno_graph::GraphKind; 16 | use deno_graph::ModuleGraph; 17 | use deno_graph::ModuleSpecifier; 18 | use indexmap::IndexMap; 19 | 20 | async fn parse() -> IndexMap> { 21 | let source = std::fs::read_to_string("./benches/fixtures/deno.d.ts").unwrap(); 22 | let sources = vec![( 23 | "file:///test/fixtures/deno.d.ts", 24 | Source::Module { 25 | specifier: "file:///test/fixtures/deno.d.ts", 26 | maybe_headers: None, 27 | content: source.as_str(), 28 | }, 29 | )]; 30 | let memory_loader = MemoryLoader::new(sources, vec![]); 31 | let root = ModuleSpecifier::parse("file:///test/fixtures/deno.d.ts").unwrap(); 32 | 33 | let analyzer = CapturingModuleAnalyzer::default(); 34 | let mut graph = ModuleGraph::new(GraphKind::TypesOnly); 35 | graph 36 | .build( 37 | vec![root.clone()], 38 | Vec::new(), 39 | &memory_loader, 40 | BuildOptions { 41 | module_analyzer: &analyzer, 42 | ..Default::default() 43 | }, 44 | ) 45 | .await; 46 | DocParser::new(&graph, &analyzer, &[root], DocParserOptions::default()) 47 | .unwrap() 48 | .parse() 49 | .unwrap() 50 | } 51 | 52 | fn doc_parser(c: &mut Criterion) { 53 | c.bench_function("parse large", |b| { 54 | b.to_async(FuturesExecutor).iter_with_large_drop(parse) 55 | }); 56 | } 57 | 58 | criterion_group!(benches, doc_parser); 59 | criterion_main!(benches); 60 | -------------------------------------------------------------------------------- /build_css.ts: -------------------------------------------------------------------------------- 1 | import $ from "@david/dax"; 2 | import browserslist from "browserslist"; 3 | import { browserslistToTargets, transform } from "lightningcss"; 4 | 5 | const browsers = browserslist(">= 0.5%, not dead"); 6 | 7 | const styles = 8 | await $`deno run -A npm:tailwindcss@3.4.3 --input src/html/templates/styles.css` 9 | .text(); 10 | const stylesWrapped = ".ddoc {" + styles + "}"; 11 | const stylesFinal = transform({ 12 | filename: "./styles.css", 13 | code: new TextEncoder().encode(stylesWrapped), 14 | minify: true, 15 | targets: browserslistToTargets(browsers), 16 | analyzeDependencies: false, 17 | }); 18 | await Deno.writeFile("src/html/templates/styles.gen.css", stylesFinal.code); 19 | 20 | const page = 21 | await $`deno run -A npm:tailwindcss@3.4.3 --config=./src/html/templates/pages/tailwind.config.ts --input src/html/templates/pages/page.css` 22 | .bytes(); 23 | const pageFinal = transform({ 24 | filename: "./page.css", 25 | code: page, 26 | minify: true, 27 | targets: browserslistToTargets(browsers), 28 | analyzeDependencies: false, 29 | }); 30 | await Deno.writeFile("src/html/templates/pages/page.gen.css", pageFinal.code); 31 | 32 | const reset = 33 | await $`deno run -A npm:tailwindcss@3.4.3 --input src/html/templates/pages/reset.css` 34 | .bytes(); 35 | const resetFinal = transform({ 36 | filename: "./reset.css", 37 | code: reset, 38 | minify: true, 39 | targets: browserslistToTargets(browsers), 40 | analyzeDependencies: false, 41 | }); 42 | await Deno.writeFile("src/html/templates/pages/reset.gen.css", resetFinal.code); 43 | 44 | const comrak = 45 | await $`deno run -A npm:tailwindcss@3.4.3 --input src/html/templates/comrak.css` 46 | .bytes(); 47 | const comrakFinal = transform({ 48 | filename: "./comrak.css", 49 | code: comrak, 50 | minify: true, 51 | targets: browserslistToTargets(browsers), 52 | analyzeDependencies: false, 53 | }); 54 | await Deno.writeFile("src/html/templates/comrak.gen.css", comrakFinal.code); 55 | -------------------------------------------------------------------------------- /deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "build": "cp LICENSE js/LICENSE && deno run -A jsr:@deno/wasmbuild@0.17.1 --project deno_doc_wasm --out js", 4 | "test": "deno test -A", 5 | "tailwind": "deno run -A build_css.ts", 6 | "gen_html": "cargo run --example ddoc -- --name=gen_html --output generated_docs/ --html", 7 | "debug": "deno task tailwind && deno task gen_html ./tests/testdata/multiple/[!_]*", 8 | "test:update": "UPDATE=1 cargo test --locked --all-targets && cargo insta test --accept" 9 | }, 10 | "workspace": ["js"], 11 | "exclude": ["target", "benches/fixtures"], 12 | "fmt": { 13 | "exclude": ["**/*.gen.css", "generated_docs"] 14 | }, 15 | "lint": { 16 | "exclude": ["src/html", "tests/testdata"] 17 | }, 18 | "imports": { 19 | "@david/dax": "jsr:@david/dax@0.40.1", 20 | "@deno/cache-dir": "jsr:@deno/cache-dir@^0.14.0", 21 | "@deno/graph": "jsr:@deno/graph@^0.82.3", 22 | "@std/assert": "jsr:@std/assert@^0.223.0", 23 | "browserslist": "npm:browserslist@4.23.0", 24 | "lightningcss": "npm:lightningcss@^1.26.0", 25 | "tailwindcss": "npm:tailwindcss@3.4.3" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /js/README.md: -------------------------------------------------------------------------------- 1 | # `deno_doc` 2 | 3 | This repository includes a compiled version of the Rust crate as Web Assembly 4 | and exposes an interface which is available via the `mod.ts`. 5 | 6 | Install: 7 | 8 | ```sh 9 | deno add jsr:@deno/doc 10 | ``` 11 | 12 | Use: 13 | 14 | ```ts 15 | import { doc } from "@deno/doc"; 16 | ``` 17 | 18 | ## `doc()` 19 | 20 | The `doc()` function takes a string URL module specifier and potentially some 21 | options, and asynchronously resolves with an array of documentation nodes, which 22 | represent the surface API of the module. 23 | 24 | A minimal example of using `doc()` and printing out some information about a 25 | function: 26 | 27 | ```ts 28 | import { doc } from "@deno/doc"; 29 | 30 | const colorsDoc = await doc("https://deno.land/std/fmt/colors.ts"); 31 | 32 | for (const node of colorsDoc) { 33 | console.log(`name: ${node.name} kind: ${node.kind}`); 34 | } 35 | ``` 36 | 37 | The `doc()` function needs a way to retrieve modules, and by default uses a 38 | `load()` function provided by `deno_graph` which uses `fetch()` for remote 39 | modules and `Deno.readFile()` for local modules. This means that `doc()` will 40 | require that appropriate read/net permissions to function properly. It will 41 | prompt for them if not provided at startup. 42 | 43 | ## DocNode 44 | 45 | The foundational type for the documentation is the `DocNode` and is exported 46 | from the `mod.ts`. 47 | -------------------------------------------------------------------------------- /js/allow_leak_test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. 2 | 3 | import { assertRejects } from "@std/assert"; 4 | import { doc } from "./mod.ts"; 5 | 6 | Deno.test({ 7 | name: "doc() - missing specifier", 8 | // TODO(@kitsonk) - remove when new deno_graph crate published 9 | sanitizeResources: false, 10 | async fn() { 11 | await assertRejects( 12 | async () => { 13 | await doc(["https://deno.land/x/bad.ts"]); 14 | }, 15 | Error, 16 | `Module not found "https://deno.land/x/bad.ts".`, 17 | ); 18 | }, 19 | }); 20 | -------------------------------------------------------------------------------- /js/deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@deno/doc", 3 | "version": "0.0.0", 4 | "exports": { 5 | ".": "./mod.ts", 6 | "./types": "./types.d.ts", 7 | "./html-types": "./html_types.d.ts" 8 | }, 9 | "exclude": [ 10 | "!**" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deno_doc_wasm" 3 | version = "0.0.0" 4 | edition = "2021" 5 | homepage = "https://deno.land/" 6 | repository = "https://github.com/denoland/deno_doc" 7 | documentation = "https://docs.rs/deno_doc" 8 | authors = ["the Deno authors"] 9 | license = "MIT" 10 | 11 | [lib] 12 | name = "deno_doc_wasm" 13 | path = "lib.rs" 14 | crate-type = ["cdylib"] 15 | 16 | [dependencies] 17 | anyhow = "1.0.86" 18 | deno_graph = { workspace = true } 19 | deno_doc = { path = "../", default-features = false } 20 | import_map.workspace = true 21 | serde.workspace = true 22 | indexmap = "2.6.0" 23 | deno_error = { version = "0.6.0", features = ["url"] } 24 | 25 | console_error_panic_hook = "0.1.7" 26 | js-sys = "=0.3.69" 27 | serde-wasm-bindgen = "=0.5.0" 28 | wasm-bindgen = "=0.2.92" 29 | wasm-bindgen-futures = "=0.4.42" 30 | 31 | [dev-dependencies] 32 | pretty_assertions = "1.4.0" 33 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.85.0" 3 | components = ["rustfmt", "clippy"] 4 | -------------------------------------------------------------------------------- /src/enum.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. 2 | 3 | use deno_ast::SourceRangedForSpanned; 4 | use deno_graph::symbols::EsModuleInfo; 5 | use serde::Deserialize; 6 | use serde::Serialize; 7 | 8 | use crate::js_doc::JsDoc; 9 | use crate::ts_type::infer_ts_type_from_expr; 10 | use crate::ts_type::TsTypeDef; 11 | use crate::util::swc::get_location; 12 | use crate::util::swc::js_doc_for_range; 13 | use crate::Location; 14 | 15 | #[derive(Debug, Serialize, Deserialize, Clone)] 16 | #[serde(rename_all = "camelCase")] 17 | pub struct EnumMemberDef { 18 | pub name: String, 19 | #[serde(skip_serializing_if = "Option::is_none", default)] 20 | pub init: Option, 21 | #[serde(skip_serializing_if = "JsDoc::is_empty", default)] 22 | pub js_doc: JsDoc, 23 | pub location: Location, 24 | } 25 | 26 | #[derive(Debug, Serialize, Deserialize, Clone)] 27 | #[serde(rename_all = "camelCase")] 28 | pub struct EnumDef { 29 | pub members: Vec, 30 | } 31 | 32 | pub fn get_doc_for_ts_enum_decl( 33 | module_info: &EsModuleInfo, 34 | enum_decl: &deno_ast::swc::ast::TsEnumDecl, 35 | ) -> (String, EnumDef) { 36 | let enum_name = enum_decl.id.sym.to_string(); 37 | let mut members = vec![]; 38 | 39 | for enum_member in &enum_decl.members { 40 | use deno_ast::swc::ast::TsEnumMemberId::*; 41 | 42 | if let Some(js_doc) = js_doc_for_range(module_info, &enum_member.range()) { 43 | let name = match &enum_member.id { 44 | Ident(ident) => ident.sym.to_string(), 45 | Str(str_) => str_.value.to_string(), 46 | }; 47 | let init = if let Some(expr) = &enum_member.init { 48 | infer_ts_type_from_expr(module_info, expr, true) 49 | } else { 50 | None 51 | }; 52 | 53 | let member_def = EnumMemberDef { 54 | name, 55 | init, 56 | js_doc, 57 | location: get_location(module_info, enum_member.start()), 58 | }; 59 | members.push(member_def); 60 | } 61 | } 62 | 63 | let enum_def = EnumDef { members }; 64 | 65 | (enum_name, enum_def) 66 | } 67 | -------------------------------------------------------------------------------- /src/html/parameters.rs: -------------------------------------------------------------------------------- 1 | use super::render_context::RenderContext; 2 | use super::types::render_type_def_colon; 3 | use crate::params::ParamDef; 4 | use crate::params::ParamPatternDef; 5 | 6 | pub(crate) fn render_params( 7 | ctx: &RenderContext, 8 | params: &[ParamDef], 9 | ) -> String { 10 | if params.is_empty() { 11 | String::new() 12 | } else if params.len() == 1 { 13 | format!("{}", render_param(ctx, ¶ms[0], 0)) 14 | } else { 15 | let mut items = Vec::with_capacity(params.len()); 16 | 17 | for (i, def) in params.iter().enumerate() { 18 | items.push(format!("
{},
", render_param(ctx, def, i))); 19 | } 20 | 21 | let content = items.join(""); 22 | 23 | format!(r#"
{content}
"#) 24 | } 25 | } 26 | 27 | fn render_param(ctx: &RenderContext, param: &ParamDef, i: usize) -> String { 28 | let (name, _str_name) = param_name(param, i); 29 | let ts_type = if let ParamPatternDef::Assign { left, .. } = ¶m.pattern { 30 | left.ts_type.as_ref().or(param.ts_type.as_ref()) 31 | } else { 32 | param.ts_type.as_ref() 33 | }; 34 | 35 | let ts_type = ts_type 36 | .map(|ts_type| render_type_def_colon(ctx, ts_type)) 37 | .unwrap_or_default(); 38 | 39 | let question_mark = match param.pattern { 40 | ParamPatternDef::Array { optional, .. } if optional => "?", 41 | ParamPatternDef::Assign { .. } => "?", 42 | ParamPatternDef::Identifier { optional, .. } if optional => "?", 43 | ParamPatternDef::Object { optional, .. } if optional => "?", 44 | _ => "", 45 | }; 46 | 47 | format!("{name}{question_mark}{ts_type}") 48 | } 49 | 50 | pub(crate) fn param_name(param: &ParamDef, i: usize) -> (String, String) { 51 | match ¶m.pattern { 52 | ParamPatternDef::Array { .. } | ParamPatternDef::Object { .. } => ( 53 | format!(r#"unnamed {i}"#), 54 | format!(r#"(unnamed {i})"#), 55 | ), 56 | ParamPatternDef::Assign { left, .. } => param_name(left, i), 57 | ParamPatternDef::Identifier { name, .. } => { 58 | (html_escape::encode_text(name).into_owned(), name.clone()) 59 | } 60 | ParamPatternDef::Rest { arg } => ( 61 | format!("...{}", param_name(arg, i).0), 62 | format!("(...{})", param_name(arg, i).1), 63 | ), 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/html/symbols/enum.rs: -------------------------------------------------------------------------------- 1 | use crate::html::render_context::RenderContext; 2 | use crate::html::types::render_type_def; 3 | use crate::html::util::*; 4 | use crate::html::DocNodeWithContext; 5 | 6 | pub(crate) fn render_enum( 7 | render_ctx: &RenderContext, 8 | doc_node: &DocNodeWithContext, 9 | ) -> Vec { 10 | let mut members = doc_node.enum_def().unwrap().members.clone(); 11 | 12 | members.sort_by(|a, b| a.name.cmp(&b.name)); 13 | 14 | let items = members 15 | .into_iter() 16 | .map(|member| { 17 | let id = IdBuilder::new(render_ctx.ctx) 18 | .kind(IdKind::Enum) 19 | .name(doc_node.get_name()) 20 | .component(&member.name) 21 | .build(); 22 | 23 | let tags = Tag::from_js_doc(&member.js_doc); 24 | 25 | DocEntryCtx::new( 26 | render_ctx, 27 | id, 28 | Some(html_escape::encode_text(&member.name).into_owned()), 29 | None, 30 | &member 31 | .init 32 | .as_ref() 33 | .map(|init| format!(" = {}", render_type_def(render_ctx, init))) 34 | .unwrap_or_default(), 35 | tags, 36 | member.js_doc.doc.as_deref(), 37 | &member.location, 38 | ) 39 | }) 40 | .collect::>(); 41 | 42 | vec![SectionCtx::new( 43 | render_ctx, 44 | "Members", 45 | SectionContentCtx::DocEntry(items), 46 | )] 47 | } 48 | -------------------------------------------------------------------------------- /src/html/symbols/type_alias.rs: -------------------------------------------------------------------------------- 1 | use crate::html::render_context::RenderContext; 2 | use crate::html::symbols::interface::render_call_signatures; 3 | use crate::html::symbols::interface::render_index_signatures; 4 | use crate::html::symbols::interface::render_methods; 5 | use crate::html::symbols::interface::render_properties; 6 | use crate::html::types::render_type_def; 7 | use crate::html::util::*; 8 | use crate::html::DocNodeWithContext; 9 | use std::collections::HashSet; 10 | 11 | pub(crate) fn render_type_alias( 12 | ctx: &RenderContext, 13 | doc_node: &DocNodeWithContext, 14 | name: &str, 15 | ) -> Vec { 16 | let type_alias_def = doc_node.type_alias_def().unwrap(); 17 | 18 | let current_type_params = type_alias_def 19 | .type_params 20 | .iter() 21 | .map(|def| def.name.as_str()) 22 | .collect::>(); 23 | let ctx = &ctx.with_current_type_params(current_type_params); 24 | 25 | let id = IdBuilder::new(ctx.ctx) 26 | .kind(IdKind::TypeAlias) 27 | .name(name) 28 | .build(); 29 | 30 | let mut sections = vec![]; 31 | 32 | if let Some(type_params) = crate::html::types::render_type_params( 33 | ctx, 34 | &doc_node.js_doc, 35 | &type_alias_def.type_params, 36 | &doc_node.location, 37 | ) { 38 | sections.push(type_params); 39 | } 40 | 41 | if let Some(ts_type_literal) = type_alias_def.ts_type.type_literal.as_ref() { 42 | if let Some(index_signatures) = 43 | render_index_signatures(ctx, &ts_type_literal.index_signatures) 44 | { 45 | sections.push(index_signatures); 46 | } 47 | 48 | if let Some(call_signatures) = 49 | render_call_signatures(ctx, &ts_type_literal.call_signatures) 50 | { 51 | sections.push(call_signatures); 52 | } 53 | 54 | if let Some(properties) = 55 | render_properties(ctx, name, &ts_type_literal.properties) 56 | { 57 | sections.push(properties); 58 | } 59 | 60 | if let Some(methods) = render_methods(ctx, name, &ts_type_literal.methods) { 61 | sections.push(methods); 62 | } 63 | } else { 64 | sections.push(SectionCtx::new( 65 | ctx, 66 | "Definition", 67 | SectionContentCtx::DocEntry(vec![DocEntryCtx::new( 68 | ctx, 69 | id, 70 | None, 71 | None, 72 | &render_type_def(ctx, &type_alias_def.ts_type), 73 | Default::default(), 74 | None, 75 | &doc_node.location, 76 | )]), 77 | )); 78 | } 79 | 80 | sections 81 | } 82 | -------------------------------------------------------------------------------- /src/html/symbols/variable.rs: -------------------------------------------------------------------------------- 1 | use crate::html::render_context::RenderContext; 2 | use crate::html::symbols::interface::render_call_signatures; 3 | use crate::html::symbols::interface::render_index_signatures; 4 | use crate::html::symbols::interface::render_methods; 5 | use crate::html::symbols::interface::render_properties; 6 | use crate::html::types::render_type_def; 7 | use crate::html::util::*; 8 | use crate::html::DocNodeWithContext; 9 | 10 | pub(crate) fn render_variable( 11 | ctx: &RenderContext, 12 | doc_node: &DocNodeWithContext, 13 | name: &str, 14 | ) -> Vec { 15 | let variable_def = doc_node.variable_def().unwrap(); 16 | 17 | let Some(ts_type) = &variable_def.ts_type else { 18 | return vec![]; 19 | }; 20 | 21 | let id = IdBuilder::new(ctx.ctx) 22 | .kind(IdKind::Variable) 23 | .name(&doc_node.get_qualified_name()) 24 | .build(); 25 | 26 | let mut sections = vec![]; 27 | 28 | if let Some(ts_type_literal) = &ts_type.type_literal { 29 | if let Some(index_signatures) = 30 | render_index_signatures(ctx, &ts_type_literal.index_signatures) 31 | { 32 | sections.push(index_signatures); 33 | } 34 | 35 | if let Some(call_signatures) = 36 | render_call_signatures(ctx, &ts_type_literal.call_signatures) 37 | { 38 | sections.push(call_signatures); 39 | } 40 | 41 | if let Some(properties) = 42 | render_properties(ctx, name, &ts_type_literal.properties) 43 | { 44 | sections.push(properties); 45 | } 46 | 47 | if let Some(methods) = render_methods(ctx, name, &ts_type_literal.methods) { 48 | sections.push(methods); 49 | } 50 | } else { 51 | sections.push(SectionCtx::new( 52 | ctx, 53 | "Type", 54 | SectionContentCtx::DocEntry(vec![DocEntryCtx::new( 55 | ctx, 56 | id, 57 | None, 58 | None, 59 | &render_type_def(ctx, ts_type), 60 | Default::default(), 61 | None, 62 | &doc_node.location, 63 | )]), 64 | )); 65 | } 66 | 67 | sections 68 | } 69 | -------------------------------------------------------------------------------- /src/html/templates/anchor.hbs: -------------------------------------------------------------------------------- 1 | 2 | {{~> icons/link ~}} 3 | 4 | -------------------------------------------------------------------------------- /src/html/templates/breadcrumbs.hbs: -------------------------------------------------------------------------------- 1 | 30 | -------------------------------------------------------------------------------- /src/html/templates/category_panel.hbs: -------------------------------------------------------------------------------- 1 | {{#if this}} 2 |
3 | 15 |
16 | {{/if}} 17 | -------------------------------------------------------------------------------- /src/html/templates/deprecated.hbs: -------------------------------------------------------------------------------- 1 | {{~#if (ne this null)~}} 2 |
3 |
Deprecated
4 | 5 | {{~#if (ne this "")~}} 6 |
{{{this}}} {{! markdown rendering }}
7 | {{~/if~}} 8 |
9 | {{~/if~}} 10 | -------------------------------------------------------------------------------- /src/html/templates/doc_block_subtitle_class.hbs: -------------------------------------------------------------------------------- 1 | {{~#if implements~}} 2 |
3 | implements 4 | {{~#each implements~}} 5 | {{{~this~}}} {{! typedef rendering }} 6 | {{~#unless @last~}} 7 | , 8 | {{~/unless~}} 9 | {{~/each~}} 10 |
11 | {{~/if~}} 12 | 13 | {{~#with extends~}} 14 |
15 | extends 16 | {{~#if href ~}} 17 | 18 | {{~symbol~}} 19 | 20 | {{~else~}} 21 | {{symbol}} 22 | {{~/if~}} 23 | {{{type_args}}} {{! typedef rendering }} 24 |
25 | {{~else~}} 26 | {{~/with~}} 27 | -------------------------------------------------------------------------------- /src/html/templates/doc_block_subtitle_interface.hbs: -------------------------------------------------------------------------------- 1 |
2 | extends 3 | {{~#each extends~}} 4 | {{{~this~}}} {{! typedef rendering }} 5 | {{~#unless @last~}} 6 | , 7 | {{~/unless~}} 8 | {{~/each~}} 9 |
10 | -------------------------------------------------------------------------------- /src/html/templates/doc_entry.hbs: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | {{~#if tags~}} 6 |
7 | {{~#each tags~}} 8 | {{~> tag value=this ~}} 9 | {{~/each~}} 10 |
11 | {{~/if~}} 12 | 13 | 14 | {{~#if name~}} 15 | {{~> anchor anchor ~}} 16 | {{~/if~}} 17 | 18 | {{~#if name_href~}} 19 | {{{name}}} 20 | {{~else~}} 21 | {{~#if name~}} 22 | {{{name}}} 23 | {{~/if~}} 24 | {{~/if~}} 25 | {{{content}}} 26 | 27 |
28 | 29 | {{~#if source_href~}} 30 | {{~> source_button source_href ~}} 31 | {{~/if~}} 32 |
33 | 34 | {{~#if js_doc~}} 35 |
36 | {{{~js_doc~}}} {{! markdown rendering }} 37 |
38 | {{~/if~}} 39 |
40 | -------------------------------------------------------------------------------- /src/html/templates/doc_node_kind_icon.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#each this~}} 3 |
4 | {{~this.char~}} 5 |
6 | {{~/each~}} 7 |
8 | -------------------------------------------------------------------------------- /src/html/templates/example.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~> anchor anchor ~}} 3 | 4 |

5 | {{{~markdown_title~}}} {{! markdown rendering }} 6 |

7 |
8 | {{{~markdown_body~}}} {{! markdown rendering }} 9 |
10 |
11 | -------------------------------------------------------------------------------- /src/html/templates/function.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#each functions~}} 3 |
4 | 5 | {{~> anchor this.anchor ~}} 6 | 7 | {{this.name}}{{{this.summary}}} {{! typedef rendering }} 8 | 9 | 10 | {{~> deprecated this.deprecated ~}} 11 | 12 | {{~> symbol_content this.content ~}} 13 |
14 | {{~#if (not @last)~}} 15 |
16 | {{~/if~}} 17 | {{~/each~}} 18 |
19 | -------------------------------------------------------------------------------- /src/html/templates/icons/arrow.svg: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/html/templates/icons/check.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/html/templates/icons/copy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/html/templates/icons/menu.svg: -------------------------------------------------------------------------------- 1 | 8 | 16 | 24 | 32 | 33 | -------------------------------------------------------------------------------- /src/html/templates/icons/moon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/html/templates/icons/source.svg: -------------------------------------------------------------------------------- 1 | 8 | 15 | 22 | 23 | -------------------------------------------------------------------------------- /src/html/templates/icons/sun.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/html/templates/index_signature.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~> anchor anchor ~}} 3 | {{~#if readonly~}} 4 | readonly 5 | {{~/if~}} 6 | [{{{params}}}] {{! param rendering }} 7 | {{{~ts_type~}}} {{! typedef rendering }} 8 |
9 | -------------------------------------------------------------------------------- /src/html/templates/module_doc.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{~> deprecated deprecated ~}} 4 | 5 | {{~> symbol_content sections ~}} 6 |
7 |
8 | -------------------------------------------------------------------------------- /src/html/templates/namespace_section.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#each this~}} 3 |
4 | {{~> doc_node_kind_icon this.doc_node_kind_ctx ~}} 5 | 6 |
7 | 8 | {{~this.name~}} 9 | 10 | 11 |
12 | {{~#if this.docs~}} 13 | {{{~this.docs~}}} {{! markdown rendering }} 14 | {{~else~}} 15 | No documentation available 16 | {{~/if~}} 17 |
18 | 19 | {{~#if this.subitems~}} 20 |
    21 | {{~#each this.subitems~}} 22 |
  • {{this.title}}
  • 23 | {{~/each~}} 24 |
25 | {{~/if~}} 26 |
27 |
28 | {{~/each~}} 29 |
30 | -------------------------------------------------------------------------------- /src/html/templates/pages/all_symbols.hbs: -------------------------------------------------------------------------------- 1 | {{~> pages/html_head html_head_ctx ~}} 2 | {{~> category_panel categories_panel ~}} 3 |
4 | {{~> pages/top_nav ~}} 5 | 6 | {{~> pages/search_results ~}} 7 | 8 |
9 |
10 | {{~> symbol_content content ~}} 11 |
12 |
13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/html/templates/pages/darkmode_toggle.js: -------------------------------------------------------------------------------- 1 | function setTheme(theme, themeToggle) { 2 | if (theme === "dark") { 3 | document.documentElement.classList.add("dark"); 4 | localStorage.setItem("theme", "dark"); 5 | } else { 6 | document.documentElement.classList.remove("dark"); 7 | localStorage.setItem("theme", "light"); 8 | } 9 | 10 | const darkIcon = themeToggle.children[0]; 11 | const lightIcon = themeToggle.children[1]; 12 | 13 | if (theme === "dark") { 14 | darkIcon.classList.add("hidden"); 15 | lightIcon.classList.remove("hidden"); 16 | } else { 17 | darkIcon.classList.remove("hidden"); 18 | lightIcon.classList.add("hidden"); 19 | } 20 | } 21 | 22 | window.addEventListener("load", () => { 23 | const themeToggle = document.getElementById("theme-toggle"); 24 | themeToggle.removeAttribute("style"); 25 | 26 | const storedTheme = localStorage.getItem("theme"); 27 | const systemPrefersDark = 28 | window.matchMedia("(prefers-color-scheme: dark)").matches; 29 | 30 | if (storedTheme) { 31 | setTheme(storedTheme, themeToggle); 32 | } else { 33 | setTheme(systemPrefersDark ? "dark" : "light", themeToggle); 34 | } 35 | 36 | if (themeToggle) { 37 | themeToggle.addEventListener("click", () => { 38 | const isDark = document.documentElement.classList.contains("dark"); 39 | setTheme(isDark ? "light" : "dark", themeToggle); 40 | }); 41 | } 42 | }); 43 | 44 | // prevent flash 45 | const theme = localStorage.getItem("theme") || 46 | (window.matchMedia("(prefers-color-scheme: dark)").matches 47 | ? "dark" 48 | : "light"); 49 | document.documentElement.classList.add(theme); 50 | -------------------------------------------------------------------------------- /src/html/templates/pages/html_head.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{{~head_inject~}}} 12 | 13 | 14 | 15 | 16 | {{~#if (not disable_search)~}} 17 | 18 | 19 | 20 | {{~/if~}} 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /src/html/templates/pages/index.hbs: -------------------------------------------------------------------------------- 1 | {{~> pages/html_head html_head_ctx ~}} 2 | {{~> category_panel categories_panel ~}} 3 |
4 | {{~> pages/top_nav ~}} 5 | 6 | {{~> pages/search_results ~}} 7 | 8 |
9 |
10 | {{~#if usage~}} 11 | {{~> usages_large usage ~}} 12 | {{~/if~}} 13 | 14 | {{~#if module_doc~}} 15 | {{~> module_doc module_doc ~}} 16 | {{~/if~}} 17 | 18 | {{~#if overview~}} 19 | {{~> symbol_content overview ~}} 20 | {{~/if~}} 21 |
22 | 23 | {{~> toc toc_ctx ~}} 24 |
25 |
26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /src/html/templates/pages/page.css: -------------------------------------------------------------------------------- 1 | @tailwind components; 2 | @tailwind utilities; 3 | 4 | body { 5 | @apply bg-white dark:bg-backgroundDark text-black dark:text-white; 6 | } 7 | 8 | .ddoc { 9 | /* 10 | keep spacing in sync with #topnav in various places further down 11 | de-dup body styles to unsure compatibility `@deno/doc` 12 | */ 13 | @apply flex bg-white items-start gap-6 p-4 dark:bg-backgroundDark 14 | dark:text-white; 15 | 16 | &:has(#categoryPanel) { 17 | @apply lg:p-2; 18 | 19 | & > div:not(#categoryPanel) { 20 | @apply lg:pt-4; 21 | } 22 | 23 | #topnav { 24 | @apply lg:-ml-6 lg:pl-6 !important; 25 | } 26 | } 27 | 28 | &:not(:has(#categoryPanel)), 29 | &:has(#categoryPanel) > div:not(#categoryPanel) { 30 | @apply pt-1 px-6; 31 | } 32 | 33 | & > div:not(#categoryPanel) { 34 | @apply flex flex-col flex-grow; 35 | } 36 | } 37 | 38 | #categoryPanel { 39 | @apply max-lg:hidden -mt-0 pt-0 w-[250px] flex-shrink-0 top-0 sticky h-screen 40 | box-border; 41 | 42 | > ul { 43 | @apply max-h-full overflow-y-auto; 44 | } 45 | } 46 | 47 | #content { 48 | @apply mt-4; 49 | 50 | > main { 51 | @apply min-w-0 col-span-full pb-0 md:pb-8 lg:pb-12 flex flex-col gap-3 52 | flex-grow; 53 | } 54 | 55 | &:has(.toc) > main { 56 | @apply lg:col-span-3 lg:row-start-1; 57 | } 58 | } 59 | 60 | #topnav { 61 | @apply -ml-4 pl-4; 62 | } 63 | 64 | #content, #topnav > div { 65 | @apply flex flex-row justify-between gap-6 gap-8 lg:gap-12; 66 | } 67 | 68 | .toc, #searchbar { 69 | @apply flex-shrink-0 min-w-[250px] max-w-[300px]; 70 | } 71 | 72 | .toc { 73 | @apply max-sm:hidden sm:flex sm:flex-col max-lg:row-start-1 74 | lg:col-[span_1_/_-1] top-0 sticky max-h-screen h-fit box-border gap-y-4 75 | -mt-14 pt-14; 76 | 77 | > div { 78 | @apply max-h-full lg:overflow-y-auto; 79 | 80 | > *:last-child { 81 | @apply pb-4; 82 | } 83 | } 84 | } 85 | 86 | #topnav { 87 | @apply top-0 sticky z-50 py-3 h-14 bg-white/10 dark:bg-backgroundDark/90 88 | dark:text-white/90 border-b border-gray-300 dark:border-gray-700; 89 | } 90 | 91 | #theme-toggle { 92 | @apply text-gray-500 dark:text-gray-400 hover:bg-gray-100 93 | dark:hover:bg-gray-700 rounded p-1; 94 | 95 | * { 96 | @apply size-5; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/html/templates/pages/redirect.hbs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/html/templates/pages/reset.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | -------------------------------------------------------------------------------- /src/html/templates/pages/search_results.hbs: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /src/html/templates/pages/symbol.hbs: -------------------------------------------------------------------------------- 1 | {{~> pages/html_head html_head_ctx ~}} 2 | {{~> category_panel categories_panel ~}} 3 |
4 | {{~> pages/top_nav ~}} 5 | 6 | {{~> pages/search_results ~}} 7 | 8 |
9 | {{~> symbol_group symbol_group_ctx ~}} 10 | 11 | {{~> toc toc_ctx ~}} 12 |
13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/html/templates/pages/tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import { type Config } from "npm:tailwindcss@3.4.3"; 2 | 3 | export default { 4 | darkMode: "class", 5 | theme: { 6 | extend: { 7 | colors: { 8 | backgroundDark: "#121417", 9 | }, 10 | }, 11 | }, 12 | content: [ 13 | "./src/html/templates/pages/*.hbs", 14 | "./src/html/templates/pages/search.js", 15 | ], 16 | } as Config; 17 | -------------------------------------------------------------------------------- /src/html/templates/pages/top_nav.hbs: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /src/html/templates/script.js: -------------------------------------------------------------------------------- 1 | function findParent(el, find) { 2 | do { 3 | if (find(el)) { 4 | return el; 5 | } 6 | } while (el = el.parentElement); 7 | } 8 | 9 | document.addEventListener("click", (e) => { 10 | const target = findParent( 11 | e.target, 12 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 13 | ); 14 | if (target) { 15 | navigator?.clipboard?.writeText(target.dataset["copy"]); 16 | target.classList.add("copied"); 17 | setTimeout(() => target.classList.remove("copied"), 1000); 18 | } 19 | }); 20 | 21 | window.addEventListener("load", () => { 22 | const usageSelector = document.getElementById("usageSelector"); 23 | 24 | document.addEventListener("mouseup", (e) => { 25 | if ( 26 | findParent( 27 | e.target, 28 | (el) => 29 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 30 | ) 31 | ) { 32 | usageSelector.open = false; 33 | } 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/html/templates/section.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#if header~}} 3 |
4 |

5 | {{~> anchor header.anchor ~}} 6 | 7 | {{~#if header.href~}} 8 | {{header.title}} 9 | {{~else~}} 10 | {{header.title}} 11 | {{~/if~}} 12 |

13 | 14 | {{~#if header.doc~}} 15 | {{{header.doc}}} {{! markdown }} 16 | {{~/if~}} 17 |
18 | {{~/if~}} 19 | 20 | {{~#if (ne content.kind "empty")~}} 21 | {{~#if (or (eq content.kind "namespace_section") (eq content.kind "see"))~}} 22 | {{~> (lookup ../content "kind") content.content ~}} 23 | {{~else~}} 24 |
25 | {{~#each content.content~}} 26 | {{~> (lookup ../content "kind") this ~}} 27 | 28 | {{~#if (and (eq (lookup ../content "kind") "example") (not @last))~}} 29 |
30 | {{~/if~}} 31 | {{~/each~}} 32 |
33 | {{~/if~}} 34 | {{~/if~}} 35 |
36 | -------------------------------------------------------------------------------- /src/html/templates/see.hbs: -------------------------------------------------------------------------------- 1 |
    2 | {{~#each this~}} 3 |
  • {{{this}}}
  • {{! markdown }} 4 | {{~/each~}} 5 |
6 | -------------------------------------------------------------------------------- /src/html/templates/source_button.hbs: -------------------------------------------------------------------------------- 1 | 4 | {{~> icons/source ~}} 5 | 6 | -------------------------------------------------------------------------------- /src/html/templates/symbol_content.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#if docs~}} 3 | {{{~docs~}}} {{! markdown rendering }} 4 | {{~/if~}} 5 | 6 | {{~#each sections~}} 7 | {{~> section this ~}} 8 | {{~/each~}} 9 |
10 | -------------------------------------------------------------------------------- /src/html/templates/symbol_group.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#each symbols~}} 3 |
4 |
5 |
6 |
7 | {{this.kind.title_lowercase}} {{../name}} 8 |
9 | {{~#if this.subtitle ~}} 10 |
11 | {{~> (concat "doc_block_subtitle_" this.subtitle.kind) this.subtitle.value ~}} 12 |
13 | {{~/if~}} 14 | {{~#if this.tags~}} 15 |
16 | {{~#each this.tags~}} 17 | {{~> tag value=this large=true ~}} 18 | {{~/each~}} 19 |
20 | {{~/if~}} 21 |
22 | 23 | {{~#if source_href~}} 24 | {{~> source_button this.source_href ~}} 25 | {{~/if~}} 26 |
27 | 28 | {{~#if (and usage @first)~}} 29 | {{~> usages_large usage ~}} 30 | {{~/if~}} 31 | 32 | {{~> deprecated this.deprecated ~}} 33 | 34 |
35 | {{~#each this.content~}} 36 | {{~#if (eq kind "function")~}} 37 | {{~> function value ~}} 38 | {{~else~}} 39 | {{~> symbol_content value ~}} 40 | {{~/if~}} 41 | {{~/each~}} 42 |
43 |
44 | {{~/each~}} 45 |
46 | -------------------------------------------------------------------------------- /src/html/templates/tag.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{~#if large~}} 3 | {{~#if value.value~}} 4 | 5 | {{~#if (eq value.kind "permissions")~}} 6 | 7 | {{~#each value.value~}} 8 | {{this}} 9 | {{~#unless @last~}} 10 |
11 | {{~/unless~}} 12 | {{~/each~}} 13 |
14 | {{~else~}} 15 | {{~titleCase value.value~}} 16 | {{~/if~}} 17 | 18 | {{~else~}} 19 | {{~titleCase value.kind~}} 20 | {{~/if~}} 21 | 22 | {{~else~}} 23 | {{~#if value.value~}} 24 | {{~value.value~}} 25 | {{~else~}} 26 | {{~value.kind~}} 27 | {{~/if~}} 28 | {{~/if~}} 29 |
30 | -------------------------------------------------------------------------------- /src/html/templates/toc.hbs: -------------------------------------------------------------------------------- 1 | {{~#if (or usages (or top_symbols document_navigation_str))~}} 2 |
3 |
4 | {{~#if usages~}} 5 | {{~> usages usages ~}} 6 | {{~/if~}} 7 | 8 | {{~#if top_symbols~}} 9 | 30 | {{~/if~}} 31 | 32 | {{~#if document_navigation_str~}} 33 | 37 | {{~/if~}} 38 |
39 |
40 | {{~/if~}} 41 | -------------------------------------------------------------------------------- /src/html/templates/usages.hbs: -------------------------------------------------------------------------------- 1 | {{~#if composed ~}} 2 |
3 | {{~#each usages~}} 4 | 7 | 8 | 9 | {{~/each~}} 10 | 11 | 40 | 41 |
42 | {{~#each usages~}} 43 |
44 | {{{~content~}}} {{! markdown rendering }} 45 |
46 | {{~/each~}} 47 |
48 |
49 | {{~else~}} 50 |
51 |

Usage

52 | {{{~usages.[0].content~}}} {{! markdown rendering }} 53 |
54 | {{~/if~}} 55 | -------------------------------------------------------------------------------- /src/html/templates/usages_large.hbs: -------------------------------------------------------------------------------- 1 |
2 |

Usage in Deno

3 | {{{~usages.[0].content~}}} {{! markdown rendering }} 4 |
5 | -------------------------------------------------------------------------------- /src/ts_type_param.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. 2 | 3 | use crate::ts_type::TsTypeDef; 4 | use deno_ast::swc::ast::TsTypeParam; 5 | use deno_ast::swc::ast::TsTypeParamDecl; 6 | use deno_graph::symbols::EsModuleInfo; 7 | use serde::Deserialize; 8 | use serde::Serialize; 9 | use std::fmt::Display; 10 | use std::fmt::Formatter; 11 | use std::fmt::Result as FmtResult; 12 | 13 | #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] 14 | #[serde(rename_all = "camelCase")] 15 | pub struct TsTypeParamDef { 16 | pub name: String, 17 | 18 | #[serde(skip_serializing_if = "Option::is_none", default)] 19 | pub constraint: Option, 20 | 21 | #[serde(skip_serializing_if = "Option::is_none", default)] 22 | pub default: Option, 23 | } 24 | 25 | impl Display for TsTypeParamDef { 26 | fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { 27 | write!(f, "{}", self.name)?; 28 | if let Some(constraint) = &self.constraint { 29 | write!(f, " extends {}", constraint)?; 30 | } 31 | if let Some(default) = &self.default { 32 | write!(f, " = {}", default)?; 33 | } 34 | Ok(()) 35 | } 36 | } 37 | 38 | impl TsTypeParamDef { 39 | pub fn new(module_info: &EsModuleInfo, param: &TsTypeParam) -> Self { 40 | let name = param.name.sym.to_string(); 41 | let constraint = param 42 | .constraint 43 | .as_ref() 44 | .map(|constraint| TsTypeDef::new(module_info, constraint)); 45 | let default = param 46 | .default 47 | .as_ref() 48 | .map(|default| TsTypeDef::new(module_info, default)); 49 | 50 | TsTypeParamDef { 51 | name, 52 | constraint, 53 | default, 54 | } 55 | } 56 | } 57 | 58 | pub(crate) fn maybe_type_param_decl_to_type_param_defs( 59 | module_info: &EsModuleInfo, 60 | maybe_type_param_decl: Option<&TsTypeParamDecl>, 61 | ) -> Box<[TsTypeParamDef]> { 62 | if let Some(type_params_decl) = maybe_type_param_decl { 63 | type_params_decl 64 | .params 65 | .iter() 66 | .map(|type_param| TsTypeParamDef::new(module_info, type_param)) 67 | .collect::>() 68 | } else { 69 | Box::new([]) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/type_alias.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. 2 | use crate::ts_type::TsTypeDef; 3 | use crate::ts_type_param::maybe_type_param_decl_to_type_param_defs; 4 | use crate::ts_type_param::TsTypeParamDef; 5 | use deno_graph::symbols::EsModuleInfo; 6 | use serde::Deserialize; 7 | use serde::Serialize; 8 | 9 | #[derive(Debug, Serialize, Deserialize, Clone)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct TypeAliasDef { 12 | pub ts_type: TsTypeDef, 13 | pub type_params: Box<[TsTypeParamDef]>, 14 | } 15 | 16 | pub fn get_doc_for_ts_type_alias_decl( 17 | module_info: &EsModuleInfo, 18 | type_alias_decl: &deno_ast::swc::ast::TsTypeAliasDecl, 19 | ) -> (String, TypeAliasDef) { 20 | let alias_name = type_alias_decl.id.sym.to_string(); 21 | let ts_type = TsTypeDef::new(module_info, &type_alias_decl.type_ann); 22 | let type_params = maybe_type_param_decl_to_type_param_defs( 23 | module_info, 24 | type_alias_decl.type_params.as_deref(), 25 | ); 26 | let type_alias_def = TypeAliasDef { 27 | ts_type, 28 | type_params, 29 | }; 30 | 31 | (alias_name, type_alias_def) 32 | } 33 | -------------------------------------------------------------------------------- /src/util/graph.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 the Deno authors. All rights reserved. MIT license. 2 | 3 | use deno_ast::ModuleSpecifier; 4 | use deno_graph::ModuleGraph; 5 | 6 | use crate::parser::DocError; 7 | 8 | /// Resolve a deno_graph module redirecting to the types dependency if available. 9 | pub fn resolve_deno_graph_module<'a>( 10 | graph: &'a ModuleGraph, 11 | specifier: &ModuleSpecifier, 12 | ) -> Result<&'a deno_graph::Module, DocError> { 13 | graph 14 | .try_get_prefer_types(specifier) 15 | .map_err(|err| DocError::Resolve(err.to_string()))? 16 | .ok_or_else(|| { 17 | DocError::Resolve(format!("Unable to load specifier: \"{}\"", specifier)) 18 | }) 19 | } 20 | -------------------------------------------------------------------------------- /src/util/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 the Deno authors. All rights reserved. MIT license. 2 | 3 | pub mod graph; 4 | pub mod swc; 5 | pub mod symbol; 6 | -------------------------------------------------------------------------------- /src/util/symbol.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2023 the Deno authors. All rights reserved. MIT license. 2 | 3 | use deno_ast::ModuleSpecifier; 4 | use deno_graph::symbols::ModuleInfoRef; 5 | use deno_graph::symbols::Symbol; 6 | use deno_graph::symbols::SymbolDecl; 7 | 8 | use crate::parser::DocError; 9 | use crate::util::swc::has_ignorable_js_doc_tag; 10 | use crate::util::swc::js_doc_for_range_include_ignore; 11 | 12 | pub fn get_module_info<'a>( 13 | root_symbol: &'a deno_graph::symbols::RootSymbol, 14 | specifier: &ModuleSpecifier, 15 | ) -> Result, DocError> { 16 | match root_symbol.module_from_specifier(specifier) { 17 | Some(symbol) => Ok(symbol), 18 | None => Err(DocError::Resolve(format!( 19 | "Could not find module in graph: {}", 20 | specifier 21 | ))), 22 | } 23 | } 24 | 25 | pub fn symbol_has_ignorable_js_doc_tag( 26 | module: ModuleInfoRef, 27 | symbol: &Symbol, 28 | ) -> bool { 29 | debug_assert_eq!(module.module_id(), symbol.module_id()); 30 | if symbol 31 | .decls() 32 | .iter() 33 | .any(|decl| decl_has_ignorable_js_doc_tag(module, decl)) 34 | { 35 | return true; 36 | } 37 | let parent_symbol = symbol.parent_id().and_then(|id| module.symbol(id)); 38 | if let Some(parent_symbol) = parent_symbol { 39 | symbol_has_ignorable_js_doc_tag(module, parent_symbol) 40 | } else { 41 | false 42 | } 43 | } 44 | 45 | fn decl_has_ignorable_js_doc_tag( 46 | module: ModuleInfoRef, 47 | decl: &SymbolDecl, 48 | ) -> bool { 49 | let Some(module) = module.esm() else { 50 | return false; 51 | }; 52 | let js_doc = js_doc_for_range_include_ignore(module.source(), &decl.range); 53 | has_ignorable_js_doc_tag(&js_doc) 54 | } 55 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import { type Config } from "tailwindcss"; 2 | 3 | const TAG_PURPLE = "#7B61FF"; 4 | const TAG_CYAN = "#0CAFC6"; 5 | 6 | const extraColors = { 7 | "Function": "#056CF0", 8 | "FunctionDark": "#4cc3ff", 9 | "Method": "#056CF0", 10 | "MethodDark": "#4cc3ff", 11 | "Variable": "#7E57C0", 12 | "VariableDark": "#b37feb", 13 | "Property": "#7E57C0", 14 | "PropertyDark": "#b37feb", 15 | "Class": "#20B44B", 16 | "ClassDark": "#87eea4", 17 | "Enum": "#22ABB0", 18 | "EnumDark": "#3fced1", 19 | "Interface": "#D2A064", 20 | "InterfaceDark": "#bb733b", 21 | "TypeAlias": "#A4478C", 22 | "TypeAliasDark": "#dd95cc", 23 | "Namespace": "#D25646", 24 | "NamespaceDark": "#e57e6b", 25 | 26 | "new": TAG_PURPLE, 27 | "abstract": TAG_CYAN, 28 | "deprecated": "#DC2626", // red 600 29 | "unstable": TAG_PURPLE, 30 | "writeonly": TAG_PURPLE, 31 | "readonly": TAG_PURPLE, 32 | "protected": TAG_PURPLE, 33 | "private": TAG_CYAN, 34 | "optional": TAG_CYAN, 35 | "permissions": TAG_CYAN, 36 | "other": "#57534E", // stone 600 37 | }; 38 | 39 | export default { 40 | content: [ 41 | "./src/html/**/*.rs", 42 | "./src/html/templates/*.hbs", 43 | ], 44 | darkMode: "class", 45 | safelist: [ 46 | { 47 | pattern: new RegExp(`^text-(${Object.keys(extraColors).join("|")})$`), 48 | variants: ["dark"], 49 | }, 50 | { 51 | pattern: new RegExp( 52 | `^border-(${Object.keys(extraColors).join("|")})\/50$`, 53 | ), 54 | }, 55 | { 56 | pattern: new RegExp( 57 | `^bg-(${Object.keys(extraColors).join("|")})\/(?:5|15)$`, 58 | ), 59 | variants: ["hover", "dark"], 60 | }, 61 | ], 62 | theme: { 63 | extend: { 64 | colors: { 65 | ...extraColors, 66 | "contextLink": "#0E6590", 67 | "contextLinkDark": "#86d3f3", 68 | backgroundDark: "#121417", 69 | gray: { 70 | 1: "#868789", 71 | }, 72 | }, 73 | borderWidth: { 74 | "1.5": "1.5px", 75 | }, 76 | margin: { 77 | "indent": "2ch", 78 | }, 79 | maxWidth: { 80 | "prose": "75ch", 81 | }, 82 | }, 83 | }, 84 | } as Config; 85 | -------------------------------------------------------------------------------- /tests/helpers/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. 2 | 3 | use deno_ast::ModuleSpecifier; 4 | use deno_doc::DocDiagnostic; 5 | use deno_doc::DocParser; 6 | use deno_doc::DocParserOptions; 7 | use deno_doc::DocPrinter; 8 | use deno_graph::source::MemoryLoader; 9 | use deno_graph::BuildOptions; 10 | use deno_graph::CapturingModuleAnalyzer; 11 | use deno_graph::GraphKind; 12 | 13 | pub struct BuildResult { 14 | pub json_output: serde_json::Value, 15 | pub text_output: String, 16 | pub diagnostics: Vec, 17 | } 18 | 19 | pub struct TestBuilder { 20 | loader: MemoryLoader, 21 | private: bool, 22 | entry_point: String, 23 | } 24 | 25 | impl TestBuilder { 26 | pub fn new() -> Self { 27 | Self { 28 | private: false, 29 | loader: Default::default(), 30 | entry_point: "file:///mod.ts".to_string(), 31 | } 32 | } 33 | 34 | pub fn with_loader( 35 | &mut self, 36 | mut action: impl FnMut(&mut MemoryLoader), 37 | ) -> &mut Self { 38 | action(&mut self.loader); 39 | self 40 | } 41 | 42 | pub fn set_private(&mut self, value: bool) -> &mut Self { 43 | self.private = value; 44 | self 45 | } 46 | 47 | pub async fn build(&mut self) -> BuildResult { 48 | let analyzer = CapturingModuleAnalyzer::default(); 49 | let mut graph = deno_graph::ModuleGraph::new(GraphKind::TypesOnly); 50 | let entry_point_url = ModuleSpecifier::parse(&self.entry_point).unwrap(); 51 | let roots = vec![entry_point_url.clone()]; 52 | graph 53 | .build( 54 | roots.clone(), 55 | Vec::new(), 56 | &self.loader, 57 | BuildOptions { 58 | module_analyzer: &analyzer, 59 | ..Default::default() 60 | }, 61 | ) 62 | .await; 63 | graph.valid().unwrap(); 64 | let entrypoints = &[entry_point_url]; 65 | let parser = DocParser::new( 66 | &graph, 67 | &analyzer, 68 | entrypoints, 69 | DocParserOptions { 70 | private: self.private, 71 | diagnostics: true, 72 | }, 73 | ) 74 | .unwrap(); 75 | 76 | let entries = parser.parse().unwrap().into_values().next().unwrap(); 77 | 78 | let doc = DocPrinter::new(&entries, false, self.private).to_string(); 79 | let diagnostics = parser.take_diagnostics(); 80 | 81 | BuildResult { 82 | diagnostics, 83 | json_output: serde_json::to_value(entries).unwrap(), 84 | text_output: doc, 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_dts-10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function setTheme(theme, themeToggle) { 6 | if (theme === "dark") { 7 | document.documentElement.classList.add("dark"); 8 | localStorage.setItem("theme", "dark"); 9 | } else { 10 | document.documentElement.classList.remove("dark"); 11 | localStorage.setItem("theme", "light"); 12 | } 13 | 14 | const darkIcon = themeToggle.children[0]; 15 | const lightIcon = themeToggle.children[1]; 16 | 17 | if (theme === "dark") { 18 | darkIcon.classList.add("hidden"); 19 | lightIcon.classList.remove("hidden"); 20 | } else { 21 | darkIcon.classList.remove("hidden"); 22 | lightIcon.classList.add("hidden"); 23 | } 24 | } 25 | 26 | window.addEventListener("load", () => { 27 | const themeToggle = document.getElementById("theme-toggle"); 28 | themeToggle.removeAttribute("style"); 29 | 30 | const storedTheme = localStorage.getItem("theme"); 31 | const systemPrefersDark = 32 | window.matchMedia("(prefers-color-scheme: dark)").matches; 33 | 34 | if (storedTheme) { 35 | setTheme(storedTheme, themeToggle); 36 | } else { 37 | setTheme(systemPrefersDark ? "dark" : "light", themeToggle); 38 | } 39 | 40 | if (themeToggle) { 41 | themeToggle.addEventListener("click", () => { 42 | const isDark = document.documentElement.classList.contains("dark"); 43 | setTheme(isDark ? "light" : "dark", themeToggle); 44 | }); 45 | } 46 | }); 47 | 48 | // prevent flash 49 | const theme = localStorage.getItem("theme") || 50 | (window.matchMedia("(prefers-color-scheme: dark)").matches 51 | ? "dark" 52 | : "light"); 53 | document.documentElement.classList.add(theme); 54 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_dts-12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function findParent(el, find) { 6 | do { 7 | if (find(el)) { 8 | return el; 9 | } 10 | } while (el = el.parentElement); 11 | } 12 | 13 | document.addEventListener("click", (e) => { 14 | const target = findParent( 15 | e.target, 16 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 17 | ); 18 | if (target) { 19 | navigator?.clipboard?.writeText(target.dataset["copy"]); 20 | target.classList.add("copied"); 21 | setTimeout(() => target.classList.remove("copied"), 1000); 22 | } 23 | }); 24 | 25 | window.addEventListener("load", () => { 26 | const usageSelector = document.getElementById("usageSelector"); 27 | 28 | document.addEventListener("mouseup", (e) => { 29 | if ( 30 | findParent( 31 | e.target, 32 | (el) => 33 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 34 | ) 35 | ) { 36 | usageSelector.open = false; 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_dts-14.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | (function () { 6 | window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"id":"namespace_ResponseInit","kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"ResponseInit","file":".","doc":"","url":"././~/ResponseInit.html","deprecated":false},{"id":"namespace_ResponseInit","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.status","file":".","doc":"","url":"././~/ResponseInit.status.html","deprecated":false},{"id":"namespace_ResponseInit","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"ResponseInit.statusText","file":".","doc":"","url":"././~/ResponseInit.statusText.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"I","kind":"Interface","title":"Interface"},{"char":"v","kind":"Variable","title":"Variable"}],"name":"WebSocket","file":".","doc":"","url":"././~/WebSocket.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.bufferedAmount","file":".","doc":"","url":"././~/WebSocket.bufferedAmount.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.prototype","file":".","doc":"","url":"././~/WebSocket.prototype.html","deprecated":false},{"id":"namespace_WebSocket","kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"WebSocket.OPEN","file":".","doc":"","url":"././~/WebSocket.OPEN.html","deprecated":false}]}; 7 | })() 8 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function findParent(el, find) { 6 | do { 7 | if (find(el)) { 8 | return el; 9 | } 10 | } while (el = el.parentElement); 11 | } 12 | 13 | document.addEventListener("click", (e) => { 14 | const target = findParent( 15 | e.target, 16 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 17 | ); 18 | if (target) { 19 | navigator?.clipboard?.writeText(target.dataset["copy"]); 20 | target.classList.add("copied"); 21 | setTimeout(() => target.classList.remove("copied"), 1000); 22 | } 23 | }); 24 | 25 | window.addEventListener("load", () => { 26 | const usageSelector = document.getElementById("usageSelector"); 27 | 28 | document.addEventListener("mouseup", (e) => { 29 | if ( 30 | findParent( 31 | e.target, 32 | (el) => 33 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 34 | ) 35 | ) { 36 | usageSelector.open = false; 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | (function () { 6 | window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"```ts\nusing time = new FakeTime();\n```","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]}; 7 | })() 8 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | 7 | 8 | documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
53 |
54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-29.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-38.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-49.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-66.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function setTheme(theme, themeToggle) { 6 | if (theme === "dark") { 7 | document.documentElement.classList.add("dark"); 8 | localStorage.setItem("theme", "dark"); 9 | } else { 10 | document.documentElement.classList.remove("dark"); 11 | localStorage.setItem("theme", "light"); 12 | } 13 | 14 | const darkIcon = themeToggle.children[0]; 15 | const lightIcon = themeToggle.children[1]; 16 | 17 | if (theme === "dark") { 18 | darkIcon.classList.add("hidden"); 19 | lightIcon.classList.remove("hidden"); 20 | } else { 21 | darkIcon.classList.remove("hidden"); 22 | lightIcon.classList.add("hidden"); 23 | } 24 | } 25 | 26 | window.addEventListener("load", () => { 27 | const themeToggle = document.getElementById("theme-toggle"); 28 | themeToggle.removeAttribute("style"); 29 | 30 | const storedTheme = localStorage.getItem("theme"); 31 | const systemPrefersDark = 32 | window.matchMedia("(prefers-color-scheme: dark)").matches; 33 | 34 | if (storedTheme) { 35 | setTheme(storedTheme, themeToggle); 36 | } else { 37 | setTheme(systemPrefersDark ? "dark" : "light", themeToggle); 38 | } 39 | 40 | if (themeToggle) { 41 | themeToggle.addEventListener("click", () => { 42 | const isDark = document.documentElement.classList.contains("dark"); 43 | setTheme(isDark ? "light" : "dark", themeToggle); 44 | }); 45 | } 46 | }); 47 | 48 | // prevent flash 49 | const theme = localStorage.getItem("theme") || 50 | (window.matchMedia("(prefers-color-scheme: dark)").matches 51 | ? "dark" 52 | : "light"); 53 | document.documentElement.classList.add(theme); 54 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-71.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function findParent(el, find) { 6 | do { 7 | if (find(el)) { 8 | return el; 9 | } 10 | } while (el = el.parentElement); 11 | } 12 | 13 | document.addEventListener("click", (e) => { 14 | const target = findParent( 15 | e.target, 16 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 17 | ); 18 | if (target) { 19 | navigator?.clipboard?.writeText(target.dataset["copy"]); 20 | target.classList.add("copied"); 21 | setTimeout(() => target.classList.remove("copied"), 1000); 22 | } 23 | }); 24 | 25 | window.addEventListener("load", () => { 26 | const usageSelector = document.getElementById("usageSelector"); 27 | 28 | document.addEventListener("mouseup", (e) => { 29 | if ( 30 | findParent( 31 | e.target, 32 | (el) => 33 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 34 | ) 35 | ) { 36 | usageSelector.open = false; 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_multiple-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-27.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-36.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-47.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-68.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function findParent(el, find) { 6 | do { 7 | if (find(el)) { 8 | return el; 9 | } 10 | } while (el = el.parentElement); 11 | } 12 | 13 | document.addEventListener("click", (e) => { 14 | const target = findParent( 15 | e.target, 16 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 17 | ); 18 | if (target) { 19 | navigator?.clipboard?.writeText(target.dataset["copy"]); 20 | target.classList.add("copied"); 21 | setTimeout(() => target.classList.remove("copied"), 1000); 22 | } 23 | }); 24 | 25 | window.addEventListener("load", () => { 26 | const usageSelector = document.getElementById("usageSelector"); 27 | 28 | document.addEventListener("mouseup", (e) => { 29 | if ( 30 | findParent( 31 | e.target, 32 | (el) => 33 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 34 | ) 35 | ) { 36 | usageSelector.open = false; 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_rewrite-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function findParent(el, find) { 6 | do { 7 | if (find(el)) { 8 | return el; 9 | } 10 | } while (el = el.parentElement); 11 | } 12 | 13 | document.addEventListener("click", (e) => { 14 | const target = findParent( 15 | e.target, 16 | (el) => el instanceof HTMLButtonElement && el.dataset["copy"], 17 | ); 18 | if (target) { 19 | navigator?.clipboard?.writeText(target.dataset["copy"]); 20 | target.classList.add("copied"); 21 | setTimeout(() => target.classList.remove("copied"), 1000); 22 | } 23 | }); 24 | 25 | window.addEventListener("load", () => { 26 | const usageSelector = document.getElementById("usageSelector"); 27 | 28 | document.addEventListener("mouseup", (e) => { 29 | if ( 30 | findParent( 31 | e.target, 32 | (el) => 33 | el.parentElement === usageSelector && el instanceof HTMLDivElement, 34 | ) 35 | ) { 36 | usageSelector.open = false; 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | (function () { 6 | window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"id":"namespace_Bar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"id":"namespace_Foo","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"","url":"././~/Foo.html","deprecated":false},{"id":"namespace_Foobar","kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]}; 7 | })() 8 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/html_test__html_doc_files_single-9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/html_test.rs 3 | expression: files.get(file_name).unwrap() 4 | --- 5 | function setTheme(theme, themeToggle) { 6 | if (theme === "dark") { 7 | document.documentElement.classList.add("dark"); 8 | localStorage.setItem("theme", "dark"); 9 | } else { 10 | document.documentElement.classList.remove("dark"); 11 | localStorage.setItem("theme", "light"); 12 | } 13 | 14 | const darkIcon = themeToggle.children[0]; 15 | const lightIcon = themeToggle.children[1]; 16 | 17 | if (theme === "dark") { 18 | darkIcon.classList.add("hidden"); 19 | lightIcon.classList.remove("hidden"); 20 | } else { 21 | darkIcon.classList.remove("hidden"); 22 | lightIcon.classList.add("hidden"); 23 | } 24 | } 25 | 26 | window.addEventListener("load", () => { 27 | const themeToggle = document.getElementById("theme-toggle"); 28 | themeToggle.removeAttribute("style"); 29 | 30 | const storedTheme = localStorage.getItem("theme"); 31 | const systemPrefersDark = 32 | window.matchMedia("(prefers-color-scheme: dark)").matches; 33 | 34 | if (storedTheme) { 35 | setTheme(storedTheme, themeToggle); 36 | } else { 37 | setTheme(systemPrefersDark ? "dark" : "light", themeToggle); 38 | } 39 | 40 | if (themeToggle) { 41 | themeToggle.addEventListener("click", () => { 42 | const isDark = document.documentElement.classList.contains("dark"); 43 | setTheme(isDark ? "light" : "dark", themeToggle); 44 | }); 45 | } 46 | }); 47 | 48 | // prevent flash 49 | const theme = localStorage.getItem("theme") || 50 | (window.matchMedia("(prefers-color-scheme: dark)").matches 51 | ? "dark" 52 | : "light"); 53 | document.documentElement.classList.add(theme); 54 | -------------------------------------------------------------------------------- /tests/specs/abstract_class.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export abstract class Class {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export abstract class Class {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | abstract class Class 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": true, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": null, 38 | "implements": [], 39 | "typeParams": [], 40 | "superTypeParams": [] 41 | } 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/specs/abstract_class_abstract_method.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export abstract class Class { 3 | abstract method() {} 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export abstract class Class { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | abstract method() {} 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | abstract class Class 24 | 25 | abstract method(): void 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Class", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": true, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [], 46 | "methods": [ 47 | { 48 | "accessibility": null, 49 | "optional": false, 50 | "isAbstract": true, 51 | "isStatic": false, 52 | "name": "method", 53 | "kind": "method", 54 | "functionDef": { 55 | "params": [], 56 | "returnType": { 57 | "repr": "void", 58 | "kind": "keyword", 59 | "keyword": "void" 60 | }, 61 | "hasBody": true, 62 | "isAsync": false, 63 | "isGenerator": false, 64 | "typeParams": [] 65 | }, 66 | "location": { 67 | "filename": "file:///mod.ts", 68 | "line": 2, 69 | "col": 2, 70 | "byteIndex": 32 71 | } 72 | } 73 | ], 74 | "extends": null, 75 | "implements": [], 76 | "typeParams": [], 77 | "superTypeParams": [] 78 | } 79 | } 80 | ] 81 | -------------------------------------------------------------------------------- /tests/specs/class_async_method.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class { 3 | async amethod(v) {} 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class Class { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | async amethod(v) {} 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class Class 24 | 25 | async amethod(v): Promise 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Class", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [], 46 | "methods": [ 47 | { 48 | "accessibility": null, 49 | "optional": false, 50 | "isAbstract": false, 51 | "isStatic": false, 52 | "name": "amethod", 53 | "kind": "method", 54 | "functionDef": { 55 | "params": [ 56 | { 57 | "kind": "identifier", 58 | "name": "v", 59 | "optional": false, 60 | "tsType": null 61 | } 62 | ], 63 | "returnType": { 64 | "repr": "Promise", 65 | "kind": "typeRef", 66 | "typeRef": { 67 | "typeParams": [ 68 | { 69 | "repr": "void", 70 | "kind": "keyword", 71 | "keyword": "void" 72 | } 73 | ], 74 | "typeName": "Promise" 75 | } 76 | }, 77 | "hasBody": true, 78 | "isAsync": true, 79 | "isGenerator": false, 80 | "typeParams": [] 81 | }, 82 | "location": { 83 | "filename": "file:///mod.ts", 84 | "line": 2, 85 | "col": 2, 86 | "byteIndex": 23 87 | } 88 | } 89 | ], 90 | "extends": null, 91 | "implements": [], 92 | "typeParams": [], 93 | "superTypeParams": [] 94 | } 95 | } 96 | ] 97 | -------------------------------------------------------------------------------- /tests/specs/class_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export class Class {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | class Class 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": false, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": null, 38 | "implements": [], 39 | "typeParams": [], 40 | "superTypeParams": [] 41 | } 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/specs/class_details.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class C { 3 | /** a doc */ 4 | a() {} 5 | f: number; 6 | } 7 | 8 | # diagnostics 9 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 10 | --> /mod.ts:1:1 11 | | 12 | 1 | export class C { 13 | | ^ 14 | 15 | 16 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 17 | --> /mod.ts:4:3 18 | | 19 | 4 | f: number; 20 | | ^ 21 | 22 | # output.txt 23 | Defined in file:///mod.ts:1:1 24 | 25 | class C 26 | 27 | f: number 28 | a(): void 29 | a doc 30 | 31 | 32 | # output.json 33 | [ 34 | { 35 | "name": "C", 36 | "isDefault": false, 37 | "location": { 38 | "filename": "file:///mod.ts", 39 | "line": 1, 40 | "col": 0, 41 | "byteIndex": 0 42 | }, 43 | "declarationKind": "export", 44 | "kind": "class", 45 | "classDef": { 46 | "isAbstract": false, 47 | "constructors": [], 48 | "properties": [ 49 | { 50 | "tsType": { 51 | "repr": "number", 52 | "kind": "keyword", 53 | "keyword": "number" 54 | }, 55 | "readonly": false, 56 | "accessibility": null, 57 | "optional": false, 58 | "isAbstract": false, 59 | "isStatic": false, 60 | "name": "f", 61 | "location": { 62 | "filename": "file:///mod.ts", 63 | "line": 4, 64 | "col": 2, 65 | "byteIndex": 43 66 | } 67 | } 68 | ], 69 | "indexSignatures": [], 70 | "methods": [ 71 | { 72 | "jsDoc": { 73 | "doc": "a doc" 74 | }, 75 | "accessibility": null, 76 | "optional": false, 77 | "isAbstract": false, 78 | "isStatic": false, 79 | "name": "a", 80 | "kind": "method", 81 | "functionDef": { 82 | "params": [], 83 | "returnType": { 84 | "repr": "void", 85 | "kind": "keyword", 86 | "keyword": "void" 87 | }, 88 | "hasBody": true, 89 | "isAsync": false, 90 | "isGenerator": false, 91 | "typeParams": [] 92 | }, 93 | "location": { 94 | "filename": "file:///mod.ts", 95 | "line": 3, 96 | "col": 2, 97 | "byteIndex": 34 98 | } 99 | } 100 | ], 101 | "extends": null, 102 | "implements": [], 103 | "typeParams": [], 104 | "superTypeParams": [] 105 | } 106 | } 107 | ] 108 | -------------------------------------------------------------------------------- /tests/specs/class_extends.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class extends Object {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export class Class extends Object {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | class Class extends Object 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": false, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": "Object", 38 | "implements": [], 39 | "typeParams": [], 40 | "superTypeParams": [] 41 | } 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/specs/class_extends_implements.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class extends Object implements Iterator, Iterable {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export class Class extends Object implements Iterator, Iterable {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | class Class extends Object implements Iterator, Iterable 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": false, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": "Object", 38 | "implements": [ 39 | { 40 | "repr": "Iterator", 41 | "kind": "typeRef", 42 | "typeRef": { 43 | "typeParams": null, 44 | "typeName": "Iterator" 45 | } 46 | }, 47 | { 48 | "repr": "Iterable", 49 | "kind": "typeRef", 50 | "typeRef": { 51 | "typeParams": null, 52 | "typeName": "Iterable" 53 | } 54 | } 55 | ], 56 | "typeParams": [], 57 | "superTypeParams": [] 58 | } 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /tests/specs/class_implements.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class implements Iterator {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export class Class implements Iterator {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | class Class implements Iterator 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": false, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": null, 38 | "implements": [ 39 | { 40 | "repr": "Iterator", 41 | "kind": "typeRef", 42 | "typeRef": { 43 | "typeParams": null, 44 | "typeName": "Iterator" 45 | } 46 | } 47 | ], 48 | "typeParams": [], 49 | "superTypeParams": [] 50 | } 51 | } 52 | ] 53 | -------------------------------------------------------------------------------- /tests/specs/class_implements2.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class implements Iterator, Iterable {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export class Class implements Iterator, Iterable {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | class Class implements Iterator, Iterable 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Class", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "class", 31 | "classDef": { 32 | "isAbstract": false, 33 | "constructors": [], 34 | "properties": [], 35 | "indexSignatures": [], 36 | "methods": [], 37 | "extends": null, 38 | "implements": [ 39 | { 40 | "repr": "Iterator", 41 | "kind": "typeRef", 42 | "typeRef": { 43 | "typeParams": null, 44 | "typeName": "Iterator" 45 | } 46 | }, 47 | { 48 | "repr": "Iterable", 49 | "kind": "typeRef", 50 | "typeRef": { 51 | "typeParams": null, 52 | "typeName": "Iterable" 53 | } 54 | } 55 | ], 56 | "typeParams": [], 57 | "superTypeParams": [] 58 | } 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /tests/specs/class_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class C { 3 | [key: string]: number; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class C { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | [key: string]: number; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class C 24 | 25 | [key: string]: number 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "C", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [ 46 | { 47 | "readonly": false, 48 | "params": [ 49 | { 50 | "kind": "identifier", 51 | "name": "key", 52 | "optional": false, 53 | "tsType": { 54 | "repr": "string", 55 | "kind": "keyword", 56 | "keyword": "string" 57 | } 58 | } 59 | ], 60 | "tsType": { 61 | "repr": "number", 62 | "kind": "keyword", 63 | "keyword": "number" 64 | }, 65 | "location": { 66 | "filename": "file:///mod.ts", 67 | "line": 2, 68 | "col": 2, 69 | "byteIndex": 19 70 | } 71 | } 72 | ], 73 | "methods": [], 74 | "extends": null, 75 | "implements": [], 76 | "typeParams": [], 77 | "superTypeParams": [] 78 | } 79 | } 80 | ] 81 | -------------------------------------------------------------------------------- /tests/specs/class_method.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class { 3 | method(v) {} 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class Class { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | method(v) {} 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class Class 24 | 25 | method(v): void 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Class", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [], 46 | "methods": [ 47 | { 48 | "accessibility": null, 49 | "optional": false, 50 | "isAbstract": false, 51 | "isStatic": false, 52 | "name": "method", 53 | "kind": "method", 54 | "functionDef": { 55 | "params": [ 56 | { 57 | "kind": "identifier", 58 | "name": "v", 59 | "optional": false, 60 | "tsType": null 61 | } 62 | ], 63 | "returnType": { 64 | "repr": "void", 65 | "kind": "keyword", 66 | "keyword": "void" 67 | }, 68 | "hasBody": true, 69 | "isAsync": false, 70 | "isGenerator": false, 71 | "typeParams": [] 72 | }, 73 | "location": { 74 | "filename": "file:///mod.ts", 75 | "line": 2, 76 | "col": 2, 77 | "byteIndex": 23 78 | } 79 | } 80 | ], 81 | "extends": null, 82 | "implements": [], 83 | "typeParams": [], 84 | "superTypeParams": [] 85 | } 86 | } 87 | ] 88 | -------------------------------------------------------------------------------- /tests/specs/class_private_property.txt: -------------------------------------------------------------------------------- 1 | { "private": true } 2 | # mod.ts 3 | export class Class { 4 | private property = ""; 5 | } 6 | 7 | # diagnostics 8 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 9 | --> /mod.ts:1:1 10 | | 11 | 1 | export class Class { 12 | | ^ 13 | 14 | # output.txt 15 | Defined in file:///mod.ts:1:1 16 | 17 | class Class 18 | 19 | private property: string 20 | 21 | 22 | # output.json 23 | [ 24 | { 25 | "name": "Class", 26 | "isDefault": false, 27 | "location": { 28 | "filename": "file:///mod.ts", 29 | "line": 1, 30 | "col": 0, 31 | "byteIndex": 0 32 | }, 33 | "declarationKind": "export", 34 | "kind": "class", 35 | "classDef": { 36 | "isAbstract": false, 37 | "constructors": [], 38 | "properties": [ 39 | { 40 | "tsType": { 41 | "repr": "string", 42 | "kind": "keyword", 43 | "keyword": "string" 44 | }, 45 | "readonly": false, 46 | "accessibility": "private", 47 | "optional": false, 48 | "isAbstract": false, 49 | "isStatic": false, 50 | "name": "property", 51 | "location": { 52 | "filename": "file:///mod.ts", 53 | "line": 2, 54 | "col": 2, 55 | "byteIndex": 23 56 | } 57 | } 58 | ], 59 | "indexSignatures": [], 60 | "methods": [], 61 | "extends": null, 62 | "implements": [], 63 | "typeParams": [], 64 | "superTypeParams": [] 65 | } 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /tests/specs/class_property.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class { 3 | someproperty: bool; 4 | optproperty: bigint; 5 | } 6 | 7 | # diagnostics 8 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 9 | --> /mod.ts:1:1 10 | | 11 | 1 | export class Class { 12 | | ^ 13 | 14 | 15 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 16 | --> /mod.ts:2:3 17 | | 18 | 2 | someproperty: bool; 19 | | ^ 20 | 21 | 22 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 23 | --> /mod.ts:3:3 24 | | 25 | 3 | optproperty: bigint; 26 | | ^ 27 | 28 | # output.txt 29 | Defined in file:///mod.ts:1:1 30 | 31 | class Class 32 | 33 | someproperty: bool 34 | optproperty: bigint 35 | 36 | 37 | # output.json 38 | [ 39 | { 40 | "name": "Class", 41 | "isDefault": false, 42 | "location": { 43 | "filename": "file:///mod.ts", 44 | "line": 1, 45 | "col": 0, 46 | "byteIndex": 0 47 | }, 48 | "declarationKind": "export", 49 | "kind": "class", 50 | "classDef": { 51 | "isAbstract": false, 52 | "constructors": [], 53 | "properties": [ 54 | { 55 | "tsType": { 56 | "repr": "bool", 57 | "kind": "typeRef", 58 | "typeRef": { 59 | "typeParams": null, 60 | "typeName": "bool" 61 | } 62 | }, 63 | "readonly": false, 64 | "accessibility": null, 65 | "optional": false, 66 | "isAbstract": false, 67 | "isStatic": false, 68 | "name": "someproperty", 69 | "location": { 70 | "filename": "file:///mod.ts", 71 | "line": 2, 72 | "col": 2, 73 | "byteIndex": 23 74 | } 75 | }, 76 | { 77 | "tsType": { 78 | "repr": "bigint", 79 | "kind": "keyword", 80 | "keyword": "bigint" 81 | }, 82 | "readonly": false, 83 | "accessibility": null, 84 | "optional": false, 85 | "isAbstract": false, 86 | "isStatic": false, 87 | "name": "optproperty", 88 | "location": { 89 | "filename": "file:///mod.ts", 90 | "line": 3, 91 | "col": 2, 92 | "byteIndex": 45 93 | } 94 | } 95 | ], 96 | "indexSignatures": [], 97 | "methods": [], 98 | "extends": null, 99 | "implements": [], 100 | "typeParams": [], 101 | "superTypeParams": [] 102 | } 103 | } 104 | ] 105 | -------------------------------------------------------------------------------- /tests/specs/class_readonly_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class C { 3 | readonly [key: string]: number; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class C { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | readonly [key: string]: number; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class C 24 | 25 | readonly [key: string]: number 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "C", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [ 46 | { 47 | "readonly": true, 48 | "params": [ 49 | { 50 | "kind": "identifier", 51 | "name": "key", 52 | "optional": false, 53 | "tsType": { 54 | "repr": "string", 55 | "kind": "keyword", 56 | "keyword": "string" 57 | } 58 | } 59 | ], 60 | "tsType": { 61 | "repr": "number", 62 | "kind": "keyword", 63 | "keyword": "number" 64 | }, 65 | "location": { 66 | "filename": "file:///mod.ts", 67 | "line": 2, 68 | "col": 2, 69 | "byteIndex": 19 70 | } 71 | } 72 | ], 73 | "methods": [], 74 | "extends": null, 75 | "implements": [], 76 | "typeParams": [], 77 | "superTypeParams": [] 78 | } 79 | } 80 | ] 81 | -------------------------------------------------------------------------------- /tests/specs/class_readonly_property.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class { 3 | readonly property = ""; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class Class { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | readonly property = ""; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class Class 24 | 25 | readonly property: string 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Class", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [ 45 | { 46 | "tsType": { 47 | "repr": "string", 48 | "kind": "keyword", 49 | "keyword": "string" 50 | }, 51 | "readonly": true, 52 | "accessibility": null, 53 | "optional": false, 54 | "isAbstract": false, 55 | "isStatic": false, 56 | "name": "property", 57 | "location": { 58 | "filename": "file:///mod.ts", 59 | "line": 2, 60 | "col": 2, 61 | "byteIndex": 23 62 | } 63 | } 64 | ], 65 | "indexSignatures": [], 66 | "methods": [], 67 | "extends": null, 68 | "implements": [], 69 | "typeParams": [], 70 | "superTypeParams": [] 71 | } 72 | } 73 | ] 74 | -------------------------------------------------------------------------------- /tests/specs/class_static_property.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class Class { 3 | static property = ""; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class Class { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | static property = ""; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class Class 24 | 25 | static property: string 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Class", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [ 45 | { 46 | "tsType": { 47 | "repr": "string", 48 | "kind": "keyword", 49 | "keyword": "string" 50 | }, 51 | "readonly": false, 52 | "accessibility": null, 53 | "optional": false, 54 | "isAbstract": false, 55 | "isStatic": true, 56 | "name": "property", 57 | "location": { 58 | "filename": "file:///mod.ts", 59 | "line": 2, 60 | "col": 2, 61 | "byteIndex": 23 62 | } 63 | } 64 | ], 65 | "indexSignatures": [], 66 | "methods": [], 67 | "extends": null, 68 | "implements": [], 69 | "typeParams": [], 70 | "superTypeParams": [] 71 | } 72 | } 73 | ] 74 | -------------------------------------------------------------------------------- /tests/specs/const_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export const Const = 0; 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:14 7 | | 8 | 1 | export const Const = 0; 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:14 13 | 14 | const Const: 0 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "Const", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 13, 26 | "byteIndex": 13 27 | }, 28 | "declarationKind": "export", 29 | "kind": "variable", 30 | "variableDef": { 31 | "tsType": { 32 | "repr": "0", 33 | "kind": "literal", 34 | "literal": { 35 | "kind": "number", 36 | "number": 0.0 37 | } 38 | }, 39 | "kind": "const" 40 | } 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /tests/specs/declare_namespace_ignore.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** Namespace JSdoc */ 3 | declare namespace RootNs { 4 | const a: "a"; 5 | 6 | /** Nested namespace JSDoc 7 | * @ignore 8 | */ 9 | namespace NestedNs { 10 | enum Foo { 11 | a = 1, 12 | b = 2, 13 | c = 3, 14 | } 15 | } 16 | } 17 | 18 | # diagnostics 19 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 20 | --> /mod.ts:3:11 21 | | 22 | 3 | const a: "a"; 23 | | ^ 24 | 25 | # output.txt 26 | Defined in file:///mod.ts:2:1 27 | 28 | namespace RootNs 29 | Namespace JSdoc 30 | 31 | const a: "a" 32 | 33 | 34 | # output.json 35 | [ 36 | { 37 | "name": "RootNs", 38 | "isDefault": false, 39 | "location": { 40 | "filename": "file:///mod.ts", 41 | "line": 2, 42 | "col": 0, 43 | "byteIndex": 23 44 | }, 45 | "declarationKind": "declare", 46 | "jsDoc": { 47 | "doc": "Namespace JSdoc" 48 | }, 49 | "kind": "namespace", 50 | "namespaceDef": { 51 | "elements": [ 52 | { 53 | "name": "a", 54 | "isDefault": false, 55 | "location": { 56 | "filename": "file:///mod.ts", 57 | "line": 3, 58 | "col": 10, 59 | "byteIndex": 60 60 | }, 61 | "declarationKind": "export", 62 | "kind": "variable", 63 | "variableDef": { 64 | "tsType": { 65 | "repr": "a", 66 | "kind": "literal", 67 | "literal": { 68 | "kind": "string", 69 | "string": "a" 70 | } 71 | }, 72 | "kind": "const" 73 | } 74 | } 75 | ] 76 | } 77 | } 78 | ] 79 | -------------------------------------------------------------------------------- /tests/specs/decorators_jsdoc.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** jsdoc */ 3 | @sealed 4 | export class A { 5 | a: string = "a"; 6 | } 7 | 8 | # diagnostics 9 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 10 | --> /mod.ts:4:3 11 | | 12 | 4 | a: string = "a"; 13 | | ^ 14 | 15 | # output.txt 16 | Defined in file:///mod.ts:3:1 17 | 18 | @sealed 19 | class A 20 | jsdoc 21 | 22 | a: string 23 | 24 | 25 | # output.json 26 | [ 27 | { 28 | "name": "A", 29 | "isDefault": false, 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 3, 33 | "col": 0, 34 | "byteIndex": 21 35 | }, 36 | "declarationKind": "export", 37 | "jsDoc": { 38 | "doc": "jsdoc" 39 | }, 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [ 45 | { 46 | "tsType": { 47 | "repr": "string", 48 | "kind": "keyword", 49 | "keyword": "string" 50 | }, 51 | "readonly": false, 52 | "accessibility": null, 53 | "optional": false, 54 | "isAbstract": false, 55 | "isStatic": false, 56 | "name": "a", 57 | "location": { 58 | "filename": "file:///mod.ts", 59 | "line": 4, 60 | "col": 2, 61 | "byteIndex": 40 62 | } 63 | } 64 | ], 65 | "indexSignatures": [], 66 | "methods": [], 67 | "extends": null, 68 | "implements": [], 69 | "typeParams": [], 70 | "superTypeParams": [], 71 | "decorators": [ 72 | { 73 | "name": "sealed", 74 | "location": { 75 | "filename": "file:///mod.ts", 76 | "line": 2, 77 | "col": 1, 78 | "byteIndex": 14 79 | } 80 | } 81 | ] 82 | } 83 | } 84 | ] 85 | -------------------------------------------------------------------------------- /tests/specs/default_exports_declared_earlier.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | function foo(): void {} 3 | export default foo; 4 | 5 | # diagnostics 6 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 7 | --> /mod.ts:1:1 8 | | 9 | 1 | function foo(): void {} 10 | | ^ 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:1:1 14 | 15 | function default(): void 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "default", 22 | "isDefault": true, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "function", 31 | "functionDef": { 32 | "params": [], 33 | "returnType": { 34 | "repr": "void", 35 | "kind": "keyword", 36 | "keyword": "void" 37 | }, 38 | "hasBody": true, 39 | "isAsync": false, 40 | "isGenerator": false, 41 | "typeParams": [] 42 | } 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /tests/specs/doc_printer_unsupported_tag.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** 3 | * @customtagone 4 | * @customtagtwo value 5 | */ 6 | export function noop() { 7 | } 8 | 9 | # diagnostics 10 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 11 | --> /mod.ts:5:1 12 | | 13 | 5 | export function noop() { 14 | | ^ 15 | 16 | # output.txt 17 | Defined in file:///mod.ts:5:1 18 | 19 | function noop(): void 20 | 21 | @customtagone 22 | @customtagtwo value 23 | 24 | 25 | # output.json 26 | [ 27 | { 28 | "name": "noop", 29 | "isDefault": false, 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 5, 33 | "col": 0, 34 | "byteIndex": 48 35 | }, 36 | "declarationKind": "export", 37 | "jsDoc": { 38 | "tags": [ 39 | { 40 | "kind": "unsupported", 41 | "value": "@customtagone" 42 | }, 43 | { 44 | "kind": "unsupported", 45 | "value": "@customtagtwo value" 46 | } 47 | ] 48 | }, 49 | "kind": "function", 50 | "functionDef": { 51 | "params": [], 52 | "returnType": { 53 | "repr": "void", 54 | "kind": "keyword", 55 | "keyword": "void" 56 | }, 57 | "hasBody": true, 58 | "isAsync": false, 59 | "isGenerator": false, 60 | "typeParams": [] 61 | } 62 | } 63 | ] 64 | -------------------------------------------------------------------------------- /tests/specs/enum_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export enum Enum {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export enum Enum {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | enum Enum 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Enum", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "enum", 31 | "enumDef": { 32 | "members": [] 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/specs/enum_member.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export enum Enum { 3 | First, 4 | /** There is a JsDoc */ 5 | Second, 6 | } 7 | 8 | # diagnostics 9 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 10 | --> /mod.ts:1:1 11 | | 12 | 1 | export enum Enum { 13 | | ^ 14 | 15 | # output.txt 16 | Defined in file:///mod.ts:1:1 17 | 18 | enum Enum 19 | 20 | First 21 | Second 22 | There is a JsDoc 23 | 24 | 25 | # output.json 26 | [ 27 | { 28 | "name": "Enum", 29 | "isDefault": false, 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 1, 33 | "col": 0, 34 | "byteIndex": 0 35 | }, 36 | "declarationKind": "export", 37 | "kind": "enum", 38 | "enumDef": { 39 | "members": [ 40 | { 41 | "name": "First", 42 | "location": { 43 | "filename": "file:///mod.ts", 44 | "line": 2, 45 | "col": 2, 46 | "byteIndex": 21 47 | } 48 | }, 49 | { 50 | "name": "Second", 51 | "jsDoc": { 52 | "doc": "There is a JsDoc" 53 | }, 54 | "location": { 55 | "filename": "file:///mod.ts", 56 | "line": 4, 57 | "col": 2, 58 | "byteIndex": 56 59 | } 60 | } 61 | ] 62 | } 63 | } 64 | ] 65 | -------------------------------------------------------------------------------- /tests/specs/export_default_class.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** Class doc */ 3 | export default class Foobar { 4 | /** Constructor js doc */ 5 | constructor(name: string, private private2: number, protected protected2: number) {} 6 | } 7 | # output.txt 8 | Defined in file:///mod.ts:2:1 9 | 10 | class default 11 | Class doc 12 | 13 | constructor(name: string, private private2: number, protected protected2: number) 14 | Constructor js doc 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "default", 21 | "isDefault": true, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 2, 25 | "col": 0, 26 | "byteIndex": 17 27 | }, 28 | "declarationKind": "export", 29 | "jsDoc": { 30 | "doc": "Class doc" 31 | }, 32 | "kind": "class", 33 | "classDef": { 34 | "defName": "Foobar", 35 | "isAbstract": false, 36 | "constructors": [ 37 | { 38 | "jsDoc": { 39 | "doc": "Constructor js doc" 40 | }, 41 | "accessibility": null, 42 | "hasBody": true, 43 | "name": "constructor", 44 | "params": [ 45 | { 46 | "kind": "identifier", 47 | "name": "name", 48 | "optional": false, 49 | "tsType": { 50 | "repr": "string", 51 | "kind": "keyword", 52 | "keyword": "string" 53 | } 54 | }, 55 | { 56 | "accessibility": "private", 57 | "kind": "identifier", 58 | "name": "private2", 59 | "optional": false, 60 | "tsType": { 61 | "repr": "number", 62 | "kind": "keyword", 63 | "keyword": "number" 64 | } 65 | }, 66 | { 67 | "accessibility": "protected", 68 | "kind": "identifier", 69 | "name": "protected2", 70 | "optional": false, 71 | "tsType": { 72 | "repr": "number", 73 | "kind": "keyword", 74 | "keyword": "number" 75 | } 76 | } 77 | ], 78 | "location": { 79 | "filename": "file:///mod.ts", 80 | "line": 4, 81 | "col": 4, 82 | "byteIndex": 81 83 | } 84 | } 85 | ], 86 | "properties": [], 87 | "indexSignatures": [], 88 | "methods": [], 89 | "extends": null, 90 | "implements": [], 91 | "typeParams": [], 92 | "superTypeParams": [] 93 | } 94 | } 95 | ] 96 | -------------------------------------------------------------------------------- /tests/specs/export_default_expr.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export default "foo"; 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export default "foo"; 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | var default: "foo" 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "default", 21 | "isDefault": true, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "variable", 30 | "variableDef": { 31 | "tsType": { 32 | "repr": "foo", 33 | "kind": "literal", 34 | "literal": { 35 | "kind": "string", 36 | "string": "foo" 37 | } 38 | }, 39 | "kind": "var" 40 | } 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /tests/specs/export_default_fn.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export default function foo(a: number) { 3 | return a; 4 | } 5 | /** @ignore */ 6 | export default function foo(a: number) { 7 | return a; 8 | } 9 | 10 | # diagnostics 11 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 12 | --> /mod.ts:1:1 13 | | 14 | 1 | export default function foo(a: number) { 15 | | ^ 16 | 17 | 18 | error[missing-return-type]: exported function is missing an explicit return type annotation 19 | --> /mod.ts:1:1 20 | | 21 | 1 | export default function foo(a: number) { 22 | | ^ 23 | 24 | # output.txt 25 | Defined in file:///mod.ts:1:1 26 | 27 | function default(a: number) 28 | 29 | 30 | # output.json 31 | [ 32 | { 33 | "name": "default", 34 | "isDefault": true, 35 | "location": { 36 | "filename": "file:///mod.ts", 37 | "line": 1, 38 | "col": 0, 39 | "byteIndex": 0 40 | }, 41 | "declarationKind": "export", 42 | "kind": "function", 43 | "functionDef": { 44 | "defName": "foo", 45 | "params": [ 46 | { 47 | "kind": "identifier", 48 | "name": "a", 49 | "optional": false, 50 | "tsType": { 51 | "repr": "number", 52 | "kind": "keyword", 53 | "keyword": "number" 54 | } 55 | } 56 | ], 57 | "returnType": null, 58 | "hasBody": true, 59 | "isAsync": false, 60 | "isGenerator": false, 61 | "typeParams": [] 62 | } 63 | } 64 | ] 65 | -------------------------------------------------------------------------------- /tests/specs/export_enum.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** 3 | * Some enum for good measure 4 | */ 5 | export enum Hello { 6 | World = "world", 7 | /** There is a JsDoc */ 8 | Fizz = "fizz", 9 | /** There is a JsDoc 10 | * @ignore 11 | */ 12 | Buzz = "buzz", 13 | } 14 | # output.txt 15 | Defined in file:///mod.ts:4:1 16 | 17 | enum Hello 18 | Some enum for good measure 19 | 20 | World 21 | Fizz 22 | There is a JsDoc 23 | 24 | 25 | # output.json 26 | [ 27 | { 28 | "name": "Hello", 29 | "isDefault": false, 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 4, 33 | "col": 0, 34 | "byteIndex": 38 35 | }, 36 | "declarationKind": "export", 37 | "jsDoc": { 38 | "doc": "Some enum for good measure" 39 | }, 40 | "kind": "enum", 41 | "enumDef": { 42 | "members": [ 43 | { 44 | "name": "World", 45 | "init": { 46 | "repr": "world", 47 | "kind": "literal", 48 | "literal": { 49 | "kind": "string", 50 | "string": "world" 51 | } 52 | }, 53 | "location": { 54 | "filename": "file:///mod.ts", 55 | "line": 5, 56 | "col": 4, 57 | "byteIndex": 62 58 | } 59 | }, 60 | { 61 | "name": "Fizz", 62 | "init": { 63 | "repr": "fizz", 64 | "kind": "literal", 65 | "literal": { 66 | "kind": "string", 67 | "string": "fizz" 68 | } 69 | }, 70 | "jsDoc": { 71 | "doc": "There is a JsDoc" 72 | }, 73 | "location": { 74 | "filename": "file:///mod.ts", 75 | "line": 7, 76 | "col": 4, 77 | "byteIndex": 111 78 | } 79 | } 80 | ] 81 | } 82 | } 83 | ] 84 | -------------------------------------------------------------------------------- /tests/specs/export_interface2.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface TypedIface { 3 | something(): T 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export interface TypedIface { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:5 16 | | 17 | 2 | something(): T 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | interface TypedIface 24 | 25 | something(): T 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "TypedIface", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "interface", 41 | "interfaceDef": { 42 | "extends": [], 43 | "constructors": [], 44 | "methods": [ 45 | { 46 | "name": "something", 47 | "kind": "method", 48 | "location": { 49 | "filename": "file:///mod.ts", 50 | "line": 2, 51 | "col": 4, 52 | "byteIndex": 37 53 | }, 54 | "params": [], 55 | "optional": false, 56 | "returnType": { 57 | "repr": "T", 58 | "kind": "typeRef", 59 | "typeRef": { 60 | "typeParams": null, 61 | "typeName": "T" 62 | } 63 | }, 64 | "typeParams": [] 65 | } 66 | ], 67 | "properties": [], 68 | "callSignatures": [], 69 | "indexSignatures": [], 70 | "typeParams": [ 71 | { 72 | "name": "T" 73 | } 74 | ] 75 | } 76 | } 77 | ] 78 | -------------------------------------------------------------------------------- /tests/specs/export_private.txt: -------------------------------------------------------------------------------- 1 | { "private": true } 2 | # mod.ts 3 | const foo: string = "foo"; 4 | export { foo }; 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:7 9 | | 10 | 1 | const foo: string = "foo"; 11 | | ^ 12 | 13 | # output.txt 14 | Defined in file:///mod.ts:1:7 15 | 16 | const foo: string 17 | 18 | 19 | # output.json 20 | [ 21 | { 22 | "name": "foo", 23 | "isDefault": false, 24 | "location": { 25 | "filename": "file:///mod.ts", 26 | "line": 1, 27 | "col": 6, 28 | "byteIndex": 6 29 | }, 30 | "declarationKind": "export", 31 | "kind": "variable", 32 | "variableDef": { 33 | "tsType": { 34 | "repr": "string", 35 | "kind": "keyword", 36 | "keyword": "string" 37 | }, 38 | "kind": "const" 39 | } 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /tests/specs/export_type_alias.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** Array holding numbers */ 3 | export type NumberArray = Array; 4 | # output.txt 5 | Defined in file:///mod.ts:2:1 6 | 7 | type NumberArray = Array 8 | Array holding numbers 9 | 10 | 11 | # output.json 12 | [ 13 | { 14 | "name": "NumberArray", 15 | "isDefault": false, 16 | "location": { 17 | "filename": "file:///mod.ts", 18 | "line": 2, 19 | "col": 0, 20 | "byteIndex": 29 21 | }, 22 | "declarationKind": "export", 23 | "jsDoc": { 24 | "doc": "Array holding numbers" 25 | }, 26 | "kind": "typeAlias", 27 | "typeAliasDef": { 28 | "tsType": { 29 | "repr": "Array", 30 | "kind": "typeRef", 31 | "typeRef": { 32 | "typeParams": [ 33 | { 34 | "repr": "number", 35 | "kind": "keyword", 36 | "keyword": "number" 37 | } 38 | ], 39 | "typeName": "Array" 40 | } 41 | }, 42 | "typeParams": [] 43 | } 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /tests/specs/function_array_deconstruction.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function f([a, b, ...c]) {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function f([a, b, ...c]) {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function f([a, b, ...c]): void 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "f", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "array", 34 | "elements": [ 35 | { 36 | "kind": "identifier", 37 | "name": "a", 38 | "optional": false, 39 | "tsType": null 40 | }, 41 | { 42 | "kind": "identifier", 43 | "name": "b", 44 | "optional": false, 45 | "tsType": null 46 | }, 47 | { 48 | "kind": "rest", 49 | "arg": { 50 | "kind": "identifier", 51 | "name": "c", 52 | "optional": false, 53 | "tsType": null 54 | }, 55 | "tsType": null 56 | } 57 | ], 58 | "optional": false, 59 | "tsType": null 60 | } 61 | ], 62 | "returnType": { 63 | "repr": "void", 64 | "kind": "keyword", 65 | "keyword": "void" 66 | }, 67 | "hasBody": true, 68 | "isAsync": false, 69 | "isGenerator": false, 70 | "typeParams": [] 71 | } 72 | } 73 | ] 74 | -------------------------------------------------------------------------------- /tests/specs/function_async.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export async function a() { 3 | return; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export async function a() { 11 | | ^ 12 | 13 | # output.txt 14 | Defined in file:///mod.ts:1:1 15 | 16 | async function a(): Promise 17 | 18 | 19 | # output.json 20 | [ 21 | { 22 | "name": "a", 23 | "isDefault": false, 24 | "location": { 25 | "filename": "file:///mod.ts", 26 | "line": 1, 27 | "col": 0, 28 | "byteIndex": 0 29 | }, 30 | "declarationKind": "export", 31 | "kind": "function", 32 | "functionDef": { 33 | "params": [], 34 | "returnType": { 35 | "repr": "Promise", 36 | "kind": "typeRef", 37 | "typeRef": { 38 | "typeParams": [ 39 | { 40 | "repr": "void", 41 | "kind": "keyword", 42 | "keyword": "void" 43 | } 44 | ], 45 | "typeName": "Promise" 46 | } 47 | }, 48 | "hasBody": true, 49 | "isAsync": true, 50 | "isGenerator": false, 51 | "typeParams": [] 52 | } 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /tests/specs/function_async_generator.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export async function* ag() {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export async function* ag() {} 9 | | ^ 10 | 11 | 12 | error[missing-return-type]: exported function is missing an explicit return type annotation 13 | --> /mod.ts:1:1 14 | | 15 | 1 | export async function* ag() {} 16 | | ^ 17 | 18 | # output.txt 19 | Defined in file:///mod.ts:1:1 20 | 21 | async function* ag() 22 | 23 | 24 | # output.json 25 | [ 26 | { 27 | "name": "ag", 28 | "isDefault": false, 29 | "location": { 30 | "filename": "file:///mod.ts", 31 | "line": 1, 32 | "col": 0, 33 | "byteIndex": 0 34 | }, 35 | "declarationKind": "export", 36 | "kind": "function", 37 | "functionDef": { 38 | "params": [], 39 | "returnType": null, 40 | "hasBody": true, 41 | "isAsync": true, 42 | "isGenerator": true, 43 | "typeParams": [] 44 | } 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /tests/specs/function_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function fun() {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function fun() {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function fun(): void 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "fun", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [], 32 | "returnType": { 33 | "repr": "void", 34 | "kind": "keyword", 35 | "keyword": "void" 36 | }, 37 | "hasBody": true, 38 | "isAsync": false, 39 | "isGenerator": false, 40 | "typeParams": [] 41 | } 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/specs/function_generator.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function* g() {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function* g() {} 9 | | ^ 10 | 11 | 12 | error[missing-return-type]: exported function is missing an explicit return type annotation 13 | --> /mod.ts:1:1 14 | | 15 | 1 | export function* g() {} 16 | | ^ 17 | 18 | # output.txt 19 | Defined in file:///mod.ts:1:1 20 | 21 | function* g() 22 | 23 | 24 | # output.json 25 | [ 26 | { 27 | "name": "g", 28 | "isDefault": false, 29 | "location": { 30 | "filename": "file:///mod.ts", 31 | "line": 1, 32 | "col": 0, 33 | "byteIndex": 0 34 | }, 35 | "declarationKind": "export", 36 | "kind": "function", 37 | "functionDef": { 38 | "params": [], 39 | "returnType": null, 40 | "hasBody": true, 41 | "isAsync": false, 42 | "isGenerator": true, 43 | "typeParams": [] 44 | } 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /tests/specs/function_generic.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function add(a: T, b: T) { return a + b; } 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function add(a: T, b: T) { return a + b; } 9 | | ^ 10 | 11 | 12 | error[missing-return-type]: exported function is missing an explicit return type annotation 13 | --> /mod.ts:1:1 14 | | 15 | 1 | export function add(a: T, b: T) { return a + b; } 16 | | ^ 17 | 18 | # output.txt 19 | Defined in file:///mod.ts:1:1 20 | 21 | function add(a: T, b: T) 22 | 23 | 24 | # output.json 25 | [ 26 | { 27 | "name": "add", 28 | "isDefault": false, 29 | "location": { 30 | "filename": "file:///mod.ts", 31 | "line": 1, 32 | "col": 0, 33 | "byteIndex": 0 34 | }, 35 | "declarationKind": "export", 36 | "kind": "function", 37 | "functionDef": { 38 | "params": [ 39 | { 40 | "kind": "identifier", 41 | "name": "a", 42 | "optional": false, 43 | "tsType": { 44 | "repr": "T", 45 | "kind": "typeRef", 46 | "typeRef": { 47 | "typeParams": null, 48 | "typeName": "T" 49 | } 50 | } 51 | }, 52 | { 53 | "kind": "identifier", 54 | "name": "b", 55 | "optional": false, 56 | "tsType": { 57 | "repr": "T", 58 | "kind": "typeRef", 59 | "typeRef": { 60 | "typeParams": null, 61 | "typeName": "T" 62 | } 63 | } 64 | } 65 | ], 66 | "returnType": null, 67 | "hasBody": true, 68 | "isAsync": false, 69 | "isGenerator": false, 70 | "typeParams": [ 71 | { 72 | "name": "T" 73 | } 74 | ] 75 | } 76 | } 77 | ] 78 | -------------------------------------------------------------------------------- /tests/specs/function_object_deconstruction.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function f({ a, b, ...c }) {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function f({ a, b, ...c }) {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function f({a, b, ...c}): void 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "f", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "object", 34 | "props": [ 35 | { 36 | "kind": "assign", 37 | "key": "a", 38 | "value": null 39 | }, 40 | { 41 | "kind": "assign", 42 | "key": "b", 43 | "value": null 44 | }, 45 | { 46 | "kind": "rest", 47 | "arg": { 48 | "kind": "identifier", 49 | "name": "c", 50 | "optional": false, 51 | "tsType": null 52 | } 53 | } 54 | ], 55 | "optional": false, 56 | "tsType": null 57 | } 58 | ], 59 | "returnType": { 60 | "repr": "void", 61 | "kind": "keyword", 62 | "keyword": "void" 63 | }, 64 | "hasBody": true, 65 | "isAsync": false, 66 | "isGenerator": false, 67 | "typeParams": [] 68 | } 69 | } 70 | ] 71 | -------------------------------------------------------------------------------- /tests/specs/generic_instantiated_with_tuple_type.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Generic {} 3 | export function f(): Generic<[string, number]> { return {}; } 4 | 5 | # diagnostics 6 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 7 | --> /mod.ts:1:1 8 | | 9 | 1 | export interface Generic {} 10 | | ^ 11 | 12 | 13 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 14 | --> /mod.ts:2:1 15 | | 16 | 2 | export function f(): Generic<[string, number]> { return {}; } 17 | | ^ 18 | 19 | # output.txt 20 | Defined in file:///mod.ts:2:1 21 | 22 | function f(): Generic<[string, number]> 23 | 24 | Defined in file:///mod.ts:1:1 25 | 26 | interface Generic 27 | 28 | 29 | 30 | # output.json 31 | [ 32 | { 33 | "name": "Generic", 34 | "isDefault": false, 35 | "location": { 36 | "filename": "file:///mod.ts", 37 | "line": 1, 38 | "col": 0, 39 | "byteIndex": 0 40 | }, 41 | "declarationKind": "export", 42 | "kind": "interface", 43 | "interfaceDef": { 44 | "extends": [], 45 | "constructors": [], 46 | "methods": [], 47 | "properties": [], 48 | "callSignatures": [], 49 | "indexSignatures": [], 50 | "typeParams": [ 51 | { 52 | "name": "T" 53 | } 54 | ] 55 | } 56 | }, 57 | { 58 | "name": "f", 59 | "isDefault": false, 60 | "location": { 61 | "filename": "file:///mod.ts", 62 | "line": 2, 63 | "col": 0, 64 | "byteIndex": 31 65 | }, 66 | "declarationKind": "export", 67 | "kind": "function", 68 | "functionDef": { 69 | "params": [], 70 | "returnType": { 71 | "repr": "Generic", 72 | "kind": "typeRef", 73 | "typeRef": { 74 | "typeParams": [ 75 | { 76 | "repr": "", 77 | "kind": "tuple", 78 | "tuple": [ 79 | { 80 | "repr": "string", 81 | "kind": "keyword", 82 | "keyword": "string" 83 | }, 84 | { 85 | "repr": "number", 86 | "kind": "keyword", 87 | "keyword": "number" 88 | } 89 | ] 90 | } 91 | ], 92 | "typeName": "Generic" 93 | } 94 | }, 95 | "hasBody": true, 96 | "isAsync": false, 97 | "isGenerator": false, 98 | "typeParams": [] 99 | } 100 | } 101 | ] 102 | -------------------------------------------------------------------------------- /tests/specs/import_equals.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | declare module Test { 3 | export interface Options { 4 | } 5 | } 6 | 7 | import Options = Test.Options; 8 | 9 | export { Options }; 10 | 11 | # diagnostics 12 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 13 | --> /mod.ts:2:3 14 | | 15 | 2 | export interface Options { 16 | | ^ 17 | 18 | # output.txt 19 | Defined in file:///mod.ts:2:3 20 | 21 | interface Options 22 | 23 | 24 | 25 | # output.json 26 | [ 27 | { 28 | "name": "Options", 29 | "isDefault": false, 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 2, 33 | "col": 2, 34 | "byteIndex": 24 35 | }, 36 | "declarationKind": "export", 37 | "kind": "interface", 38 | "interfaceDef": { 39 | "extends": [], 40 | "constructors": [], 41 | "methods": [], 42 | "properties": [], 43 | "callSignatures": [], 44 | "indexSignatures": [], 45 | "typeParams": [] 46 | } 47 | } 48 | ] 49 | -------------------------------------------------------------------------------- /tests/specs/import_types.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function adopt(p: import("./module.ts").Pet) { 3 | console.log(`Adopting ${p.name}...`); 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export function adopt(p: import("./module.ts").Pet) { 11 | | ^ 12 | 13 | # output.txt 14 | Defined in file:///mod.ts:1:1 15 | 16 | function adopt(p: import("./module.ts").Pet): void 17 | 18 | 19 | # output.json 20 | [ 21 | { 22 | "name": "adopt", 23 | "isDefault": false, 24 | "location": { 25 | "filename": "file:///mod.ts", 26 | "line": 1, 27 | "col": 0, 28 | "byteIndex": 0 29 | }, 30 | "declarationKind": "export", 31 | "kind": "function", 32 | "functionDef": { 33 | "params": [ 34 | { 35 | "kind": "identifier", 36 | "name": "p", 37 | "optional": false, 38 | "tsType": { 39 | "repr": "", 40 | "kind": "importType", 41 | "importType": { 42 | "specifier": "./module.ts", 43 | "qualifier": "Pet", 44 | "typeParams": [ 45 | { 46 | "repr": "T", 47 | "kind": "typeRef", 48 | "typeRef": { 49 | "typeParams": null, 50 | "typeName": "T" 51 | } 52 | } 53 | ] 54 | } 55 | } 56 | } 57 | ], 58 | "returnType": { 59 | "repr": "void", 60 | "kind": "keyword", 61 | "keyword": "void" 62 | }, 63 | "hasBody": true, 64 | "isAsync": false, 65 | "isGenerator": false, 66 | "typeParams": [ 67 | { 68 | "name": "T" 69 | } 70 | ] 71 | } 72 | } 73 | ] 74 | -------------------------------------------------------------------------------- /tests/specs/indented_with_tabs.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /** 3 | * Line 1 4 | * 5 | * Line 2 6 | * 7 | * Indented 8 | */ 9 | export namespace Tabs { 10 | /** 11 | * Line 1 12 | * 13 | * Line 2 14 | * 15 | * Indented 16 | */ 17 | export interface Tabs{ 18 | /** 19 | * Line 1 20 | * 21 | * Line 2 22 | * 23 | * Indented 24 | */ 25 | property: string; 26 | } 27 | } 28 | # output.txt 29 | Defined in file:///mod.ts:8:1 30 | 31 | namespace Tabs 32 | Line 1 33 | 34 | Line 2 35 | 36 | Indented 37 | 38 | interface Tabs 39 | Line 1 40 | 41 | Line 2 42 | 43 | Indented 44 | 45 | 46 | # output.json 47 | [ 48 | { 49 | "name": "Tabs", 50 | "isDefault": false, 51 | "location": { 52 | "filename": "file:///mod.ts", 53 | "line": 8, 54 | "col": 0, 55 | "byteIndex": 47 56 | }, 57 | "declarationKind": "export", 58 | "jsDoc": { 59 | "doc": "Line 1\n\nLine 2\n\n\tIndented" 60 | }, 61 | "kind": "namespace", 62 | "namespaceDef": { 63 | "elements": [ 64 | { 65 | "name": "Tabs", 66 | "isDefault": false, 67 | "location": { 68 | "filename": "file:///mod.ts", 69 | "line": 16, 70 | "col": 4, 71 | "byteIndex": 126 72 | }, 73 | "declarationKind": "export", 74 | "jsDoc": { 75 | "doc": "Line 1\n\nLine 2\n\n\tIndented" 76 | }, 77 | "kind": "interface", 78 | "interfaceDef": { 79 | "extends": [], 80 | "constructors": [], 81 | "methods": [], 82 | "properties": [ 83 | { 84 | "name": "property", 85 | "jsDoc": { 86 | "doc": "Line 1\n\nLine 2\n\n\tIndented" 87 | }, 88 | "location": { 89 | "filename": "file:///mod.ts", 90 | "line": 24, 91 | "col": 8, 92 | "byteIndex": 212 93 | }, 94 | "params": [], 95 | "computed": false, 96 | "optional": false, 97 | "tsType": { 98 | "repr": "string", 99 | "kind": "keyword", 100 | "keyword": "string" 101 | }, 102 | "typeParams": [] 103 | } 104 | ], 105 | "callSignatures": [], 106 | "indexSignatures": [], 107 | "typeParams": [] 108 | } 109 | } 110 | ] 111 | } 112 | } 113 | ] 114 | -------------------------------------------------------------------------------- /tests/specs/infer_function_assignment.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(n = 0, b: string = 0) {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function foo(n = 0, b: string = 0) {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function foo(n: number, b: string): void 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "foo", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "assign", 34 | "left": { 35 | "kind": "identifier", 36 | "name": "n", 37 | "optional": false, 38 | "tsType": { 39 | "repr": "number", 40 | "kind": "keyword", 41 | "keyword": "number" 42 | } 43 | }, 44 | "right": "0", 45 | "tsType": null 46 | }, 47 | { 48 | "kind": "assign", 49 | "left": { 50 | "kind": "identifier", 51 | "name": "b", 52 | "optional": false, 53 | "tsType": { 54 | "repr": "string", 55 | "kind": "keyword", 56 | "keyword": "string" 57 | } 58 | }, 59 | "right": "0", 60 | "tsType": null 61 | } 62 | ], 63 | "returnType": { 64 | "repr": "void", 65 | "kind": "keyword", 66 | "keyword": "void" 67 | }, 68 | "hasBody": true, 69 | "isAsync": false, 70 | "isGenerator": false, 71 | "typeParams": [] 72 | } 73 | } 74 | ] 75 | -------------------------------------------------------------------------------- /tests/specs/infer_types.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type Flatten = T extends Array ? U : T; 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type Flatten = T extends Array ? U : T; 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type Flatten = T extends Array ? U : T 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "Flatten", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "conditional", 34 | "conditionalType": { 35 | "checkType": { 36 | "repr": "T", 37 | "kind": "typeRef", 38 | "typeRef": { 39 | "typeParams": null, 40 | "typeName": "T" 41 | } 42 | }, 43 | "extendsType": { 44 | "repr": "Array", 45 | "kind": "typeRef", 46 | "typeRef": { 47 | "typeParams": [ 48 | { 49 | "repr": "", 50 | "kind": "infer", 51 | "infer": { 52 | "typeParam": { 53 | "name": "U" 54 | } 55 | } 56 | } 57 | ], 58 | "typeName": "Array" 59 | } 60 | }, 61 | "trueType": { 62 | "repr": "U", 63 | "kind": "typeRef", 64 | "typeRef": { 65 | "typeParams": null, 66 | "typeName": "U" 67 | } 68 | }, 69 | "falseType": { 70 | "repr": "T", 71 | "kind": "typeRef", 72 | "typeRef": { 73 | "typeParams": null, 74 | "typeName": "T" 75 | } 76 | } 77 | } 78 | }, 79 | "typeParams": [ 80 | { 81 | "name": "T" 82 | } 83 | ] 84 | } 85 | } 86 | ] 87 | -------------------------------------------------------------------------------- /tests/specs/interface_construct.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface I { 3 | new(name: string); 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export interface I { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | new(name: string); 18 | | ^ 19 | 20 | 21 | error[missing-return-type]: exported function is missing an explicit return type annotation 22 | --> /mod.ts:2:3 23 | | 24 | 2 | new(name: string); 25 | | ^ 26 | 27 | # output.txt 28 | Defined in file:///mod.ts:1:1 29 | 30 | interface I 31 | 32 | constructor(name: string) 33 | 34 | 35 | # output.json 36 | [ 37 | { 38 | "name": "I", 39 | "isDefault": false, 40 | "location": { 41 | "filename": "file:///mod.ts", 42 | "line": 1, 43 | "col": 0, 44 | "byteIndex": 0 45 | }, 46 | "declarationKind": "export", 47 | "kind": "interface", 48 | "interfaceDef": { 49 | "extends": [], 50 | "constructors": [ 51 | { 52 | "params": [ 53 | { 54 | "kind": "identifier", 55 | "name": "name", 56 | "optional": false, 57 | "tsType": { 58 | "repr": "string", 59 | "kind": "keyword", 60 | "keyword": "string" 61 | } 62 | } 63 | ], 64 | "returnType": null, 65 | "typeParams": [], 66 | "location": { 67 | "filename": "file:///mod.ts", 68 | "line": 2, 69 | "col": 2, 70 | "byteIndex": 23 71 | } 72 | } 73 | ], 74 | "methods": [], 75 | "properties": [], 76 | "callSignatures": [], 77 | "indexSignatures": [], 78 | "typeParams": [] 79 | } 80 | } 81 | ] 82 | -------------------------------------------------------------------------------- /tests/specs/interface_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export interface Interface {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | interface Interface 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Interface", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "interface", 31 | "interfaceDef": { 32 | "extends": [], 33 | "constructors": [], 34 | "methods": [], 35 | "properties": [], 36 | "callSignatures": [], 37 | "indexSignatures": [], 38 | "typeParams": [] 39 | } 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /tests/specs/interface_extends.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface extends Iterator {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export interface Interface extends Iterator {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | interface Interface extends Iterator 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Interface", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "interface", 31 | "interfaceDef": { 32 | "extends": [ 33 | { 34 | "repr": "Iterator", 35 | "kind": "typeRef", 36 | "typeRef": { 37 | "typeParams": null, 38 | "typeName": "Iterator" 39 | } 40 | } 41 | ], 42 | "constructors": [], 43 | "methods": [], 44 | "properties": [], 45 | "callSignatures": [], 46 | "indexSignatures": [], 47 | "typeParams": [] 48 | } 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /tests/specs/interface_extends2.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface extends Iterator, Iterable {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export interface Interface extends Iterator, Iterable {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | interface Interface extends Iterator, Iterable 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Interface", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "interface", 31 | "interfaceDef": { 32 | "extends": [ 33 | { 34 | "repr": "Iterator", 35 | "kind": "typeRef", 36 | "typeRef": { 37 | "typeParams": null, 38 | "typeName": "Iterator" 39 | } 40 | }, 41 | { 42 | "repr": "Iterable", 43 | "kind": "typeRef", 44 | "typeRef": { 45 | "typeParams": null, 46 | "typeName": "Iterable" 47 | } 48 | } 49 | ], 50 | "constructors": [], 51 | "methods": [], 52 | "properties": [], 53 | "callSignatures": [], 54 | "indexSignatures": [], 55 | "typeParams": [] 56 | } 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /tests/specs/interface_generic.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export interface Interface {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | interface Interface 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Interface", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "interface", 31 | "interfaceDef": { 32 | "extends": [], 33 | "constructors": [], 34 | "methods": [], 35 | "properties": [], 36 | "callSignatures": [], 37 | "indexSignatures": [], 38 | "typeParams": [ 39 | { 40 | "name": "T" 41 | } 42 | ] 43 | } 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /tests/specs/interface_generic_extends.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface extends Iterable {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export interface Interface extends Iterable {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | interface Interface extends Iterable 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Interface", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "interface", 31 | "interfaceDef": { 32 | "extends": [ 33 | { 34 | "repr": "Iterable", 35 | "kind": "typeRef", 36 | "typeRef": { 37 | "typeParams": [ 38 | { 39 | "repr": "V", 40 | "kind": "typeRef", 41 | "typeRef": { 42 | "typeParams": null, 43 | "typeName": "V" 44 | } 45 | } 46 | ], 47 | "typeName": "Iterable" 48 | } 49 | } 50 | ], 51 | "constructors": [], 52 | "methods": [], 53 | "properties": [], 54 | "callSignatures": [], 55 | "indexSignatures": [], 56 | "typeParams": [ 57 | { 58 | "name": "V" 59 | } 60 | ] 61 | } 62 | } 63 | ] 64 | -------------------------------------------------------------------------------- /tests/specs/interface_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface { 3 | [index: number]: Interface; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export interface Interface { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | [index: number]: Interface; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | interface Interface 24 | 25 | [index: number]: Interface 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Interface", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "interface", 41 | "interfaceDef": { 42 | "extends": [], 43 | "constructors": [], 44 | "methods": [], 45 | "properties": [], 46 | "callSignatures": [], 47 | "indexSignatures": [ 48 | { 49 | "readonly": false, 50 | "params": [ 51 | { 52 | "kind": "identifier", 53 | "name": "index", 54 | "optional": false, 55 | "tsType": { 56 | "repr": "number", 57 | "kind": "keyword", 58 | "keyword": "number" 59 | } 60 | } 61 | ], 62 | "tsType": { 63 | "repr": "Interface", 64 | "kind": "typeRef", 65 | "typeRef": { 66 | "typeParams": null, 67 | "typeName": "Interface" 68 | } 69 | }, 70 | "location": { 71 | "filename": "file:///mod.ts", 72 | "line": 2, 73 | "col": 2, 74 | "byteIndex": 31 75 | } 76 | } 77 | ], 78 | "typeParams": [] 79 | } 80 | } 81 | ] 82 | -------------------------------------------------------------------------------- /tests/specs/interface_number_literal_property.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface I { 3 | 1: string; 4 | 2?: number; 5 | } 6 | 7 | # diagnostics 8 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 9 | --> /mod.ts:1:1 10 | | 11 | 1 | export interface I { 12 | | ^ 13 | 14 | 15 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 16 | --> /mod.ts:2:3 17 | | 18 | 2 | 1: string; 19 | | ^ 20 | 21 | 22 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 23 | --> /mod.ts:3:3 24 | | 25 | 3 | 2?: number; 26 | | ^ 27 | 28 | # output.txt 29 | Defined in file:///mod.ts:1:1 30 | 31 | interface I 32 | 33 | 1: string 34 | 2?: number 35 | 36 | 37 | # output.json 38 | [ 39 | { 40 | "name": "I", 41 | "isDefault": false, 42 | "location": { 43 | "filename": "file:///mod.ts", 44 | "line": 1, 45 | "col": 0, 46 | "byteIndex": 0 47 | }, 48 | "declarationKind": "export", 49 | "kind": "interface", 50 | "interfaceDef": { 51 | "extends": [], 52 | "constructors": [], 53 | "methods": [], 54 | "properties": [ 55 | { 56 | "name": "1", 57 | "location": { 58 | "filename": "file:///mod.ts", 59 | "line": 2, 60 | "col": 2, 61 | "byteIndex": 23 62 | }, 63 | "params": [], 64 | "computed": false, 65 | "optional": false, 66 | "tsType": { 67 | "repr": "string", 68 | "kind": "keyword", 69 | "keyword": "string" 70 | }, 71 | "typeParams": [] 72 | }, 73 | { 74 | "name": "2", 75 | "location": { 76 | "filename": "file:///mod.ts", 77 | "line": 3, 78 | "col": 2, 79 | "byteIndex": 36 80 | }, 81 | "params": [], 82 | "computed": false, 83 | "optional": true, 84 | "tsType": { 85 | "repr": "number", 86 | "kind": "keyword", 87 | "keyword": "number" 88 | }, 89 | "typeParams": [] 90 | } 91 | ], 92 | "callSignatures": [], 93 | "indexSignatures": [], 94 | "typeParams": [] 95 | } 96 | } 97 | ] 98 | -------------------------------------------------------------------------------- /tests/specs/interface_readonly_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface Interface { 3 | readonly [index: number]: Interface; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export interface Interface { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | readonly [index: number]: Interface; 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | interface Interface 24 | 25 | readonly [index: number]: Interface 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "Interface", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "interface", 41 | "interfaceDef": { 42 | "extends": [], 43 | "constructors": [], 44 | "methods": [], 45 | "properties": [], 46 | "callSignatures": [], 47 | "indexSignatures": [ 48 | { 49 | "readonly": true, 50 | "params": [ 51 | { 52 | "kind": "identifier", 53 | "name": "index", 54 | "optional": false, 55 | "tsType": { 56 | "repr": "number", 57 | "kind": "keyword", 58 | "keyword": "number" 59 | } 60 | } 61 | ], 62 | "tsType": { 63 | "repr": "Interface", 64 | "kind": "typeRef", 65 | "typeRef": { 66 | "typeParams": null, 67 | "typeName": "Interface" 68 | } 69 | }, 70 | "location": { 71 | "filename": "file:///mod.ts", 72 | "line": 2, 73 | "col": 2, 74 | "byteIndex": 31 75 | } 76 | } 77 | ], 78 | "typeParams": [] 79 | } 80 | } 81 | ] 82 | -------------------------------------------------------------------------------- /tests/specs/interface_string_literal_property.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export interface I { 3 | "p": string; 4 | "po"?: number; 5 | } 6 | 7 | # diagnostics 8 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 9 | --> /mod.ts:1:1 10 | | 11 | 1 | export interface I { 12 | | ^ 13 | 14 | 15 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 16 | --> /mod.ts:2:3 17 | | 18 | 2 | "p": string; 19 | | ^ 20 | 21 | 22 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 23 | --> /mod.ts:3:3 24 | | 25 | 3 | "po"?: number; 26 | | ^ 27 | 28 | # output.txt 29 | Defined in file:///mod.ts:1:1 30 | 31 | interface I 32 | 33 | p: string 34 | po?: number 35 | 36 | 37 | # output.json 38 | [ 39 | { 40 | "name": "I", 41 | "isDefault": false, 42 | "location": { 43 | "filename": "file:///mod.ts", 44 | "line": 1, 45 | "col": 0, 46 | "byteIndex": 0 47 | }, 48 | "declarationKind": "export", 49 | "kind": "interface", 50 | "interfaceDef": { 51 | "extends": [], 52 | "constructors": [], 53 | "methods": [], 54 | "properties": [ 55 | { 56 | "name": "p", 57 | "location": { 58 | "filename": "file:///mod.ts", 59 | "line": 2, 60 | "col": 2, 61 | "byteIndex": 23 62 | }, 63 | "params": [], 64 | "computed": false, 65 | "optional": false, 66 | "tsType": { 67 | "repr": "string", 68 | "kind": "keyword", 69 | "keyword": "string" 70 | }, 71 | "typeParams": [] 72 | }, 73 | { 74 | "name": "po", 75 | "location": { 76 | "filename": "file:///mod.ts", 77 | "line": 3, 78 | "col": 2, 79 | "byteIndex": 38 80 | }, 81 | "params": [], 82 | "computed": false, 83 | "optional": true, 84 | "tsType": { 85 | "repr": "number", 86 | "kind": "keyword", 87 | "keyword": "number" 88 | }, 89 | "typeParams": [] 90 | } 91 | ], 92 | "callSignatures": [], 93 | "indexSignatures": [], 94 | "typeParams": [] 95 | } 96 | } 97 | ] 98 | -------------------------------------------------------------------------------- /tests/specs/module_docs.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /* a non-jsdoc comment */ 3 | 4 | /** 5 | * A leading JSDoc comment 6 | * @module 7 | */ 8 | 9 | /** One associated with a class */ 10 | export class A {} 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:3:1 14 | 15 | A leading JSDoc comment 16 | 17 | @module 18 | 19 | Defined in file:///mod.ts:9:1 20 | 21 | class A 22 | One associated with a class 23 | 24 | 25 | 26 | # output.json 27 | [ 28 | { 29 | "name": "", 30 | "location": { 31 | "filename": "file:///mod.ts", 32 | "line": 3, 33 | "col": 0, 34 | "byteIndex": 27 35 | }, 36 | "declarationKind": "export", 37 | "jsDoc": { 38 | "doc": "A leading JSDoc comment", 39 | "tags": [ 40 | { 41 | "kind": "module" 42 | } 43 | ] 44 | }, 45 | "kind": "moduleDoc" 46 | }, 47 | { 48 | "name": "A", 49 | "isDefault": false, 50 | "location": { 51 | "filename": "file:///mod.ts", 52 | "line": 9, 53 | "col": 0, 54 | "byteIndex": 109 55 | }, 56 | "declarationKind": "export", 57 | "jsDoc": { 58 | "doc": "One associated with a class" 59 | }, 60 | "kind": "class", 61 | "classDef": { 62 | "isAbstract": false, 63 | "constructors": [], 64 | "properties": [], 65 | "indexSignatures": [], 66 | "methods": [], 67 | "extends": null, 68 | "implements": [], 69 | "typeParams": [], 70 | "superTypeParams": [] 71 | } 72 | } 73 | ] 74 | -------------------------------------------------------------------------------- /tests/specs/module_docs_ignore.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /* a non-jsdoc comment */ 3 | 4 | /** 5 | * A leading JSDoc comment 6 | * @module 7 | * @ignore 8 | */ 9 | 10 | /** One associated with a class */ 11 | export class A {} 12 | # output.txt 13 | 14 | # output.json 15 | [] 16 | -------------------------------------------------------------------------------- /tests/specs/module_docs_ignore_no_module_tag.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | /* a non-jsdoc comment */ 3 | 4 | /** 5 | * A leading JSDoc comment 6 | * @ignore 7 | */ 8 | 9 | /** One associated with a class */ 10 | export class A {} 11 | # output.txt 12 | Defined in file:///mod.ts:9:1 13 | 14 | class A 15 | One associated with a class 16 | 17 | 18 | 19 | # output.json 20 | [ 21 | { 22 | "name": "A", 23 | "isDefault": false, 24 | "location": { 25 | "filename": "file:///mod.ts", 26 | "line": 9, 27 | "col": 0, 28 | "byteIndex": 109 29 | }, 30 | "declarationKind": "export", 31 | "jsDoc": { 32 | "doc": "One associated with a class" 33 | }, 34 | "kind": "class", 35 | "classDef": { 36 | "isAbstract": false, 37 | "constructors": [], 38 | "properties": [], 39 | "indexSignatures": [], 40 | "methods": [], 41 | "extends": null, 42 | "implements": [], 43 | "typeParams": [], 44 | "superTypeParams": [] 45 | } 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /tests/specs/namespace_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export namespace Namespace {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export namespace Namespace {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | namespace Namespace 15 | 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "Namespace", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "namespace", 31 | "namespaceDef": { 32 | "elements": [] 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/specs/no_ambient_in_module.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | declare function foo(): number; 3 | export function bar() {}; 4 | 5 | # diagnostics 6 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 7 | --> /mod.ts:2:1 8 | | 9 | 2 | export function bar() {}; 10 | | ^ 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:2:1 14 | 15 | function bar(): void 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "bar", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 2, 26 | "col": 0, 27 | "byteIndex": 32 28 | }, 29 | "declarationKind": "export", 30 | "kind": "function", 31 | "functionDef": { 32 | "params": [], 33 | "returnType": { 34 | "repr": "void", 35 | "kind": "keyword", 36 | "keyword": "void" 37 | }, 38 | "hasBody": true, 39 | "isAsync": false, 40 | "isGenerator": false, 41 | "typeParams": [] 42 | } 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /tests/specs/non_implemented_renamed_exports_declared_earlier.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | declare function foo(): void; 3 | export { foo as bar }; 4 | 5 | # diagnostics 6 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 7 | --> /mod.ts:1:1 8 | | 9 | 1 | declare function foo(): void; 10 | | ^ 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:1:1 14 | 15 | function bar(): void 16 | 17 | 18 | # output.json 19 | [ 20 | { 21 | "name": "bar", 22 | "isDefault": false, 23 | "location": { 24 | "filename": "file:///mod.ts", 25 | "line": 1, 26 | "col": 0, 27 | "byteIndex": 0 28 | }, 29 | "declarationKind": "export", 30 | "kind": "function", 31 | "functionDef": { 32 | "params": [], 33 | "returnType": { 34 | "repr": "void", 35 | "kind": "keyword", 36 | "keyword": "void" 37 | }, 38 | "isAsync": false, 39 | "isGenerator": false, 40 | "typeParams": [] 41 | } 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/specs/optional_return_type.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(a: number) { 3 | return a; 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export function foo(a: number) { 11 | | ^ 12 | 13 | 14 | error[missing-return-type]: exported function is missing an explicit return type annotation 15 | --> /mod.ts:1:1 16 | | 17 | 1 | export function foo(a: number) { 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | function foo(a: number) 24 | 25 | 26 | # output.json 27 | [ 28 | { 29 | "name": "foo", 30 | "isDefault": false, 31 | "location": { 32 | "filename": "file:///mod.ts", 33 | "line": 1, 34 | "col": 0, 35 | "byteIndex": 0 36 | }, 37 | "declarationKind": "export", 38 | "kind": "function", 39 | "functionDef": { 40 | "params": [ 41 | { 42 | "kind": "identifier", 43 | "name": "a", 44 | "optional": false, 45 | "tsType": { 46 | "repr": "number", 47 | "kind": "keyword", 48 | "keyword": "number" 49 | } 50 | } 51 | ], 52 | "returnType": null, 53 | "hasBody": true, 54 | "isAsync": false, 55 | "isGenerator": false, 56 | "typeParams": [] 57 | } 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /tests/specs/private_type_ignored_class_not_namespace.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | // Should not show a diagnostic for MyNamespace because MyInternal was marked as internal 3 | /** Comment */ 4 | export type PrivateProp = typeof MyNamespace.MyInternal; 5 | 6 | namespace MyNamespace { 7 | /** @internal */ 8 | export class MyInternal { 9 | } 10 | } 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:3:1 14 | 15 | type PrivateProp = typeof MyNamespace.MyInternal 16 | Comment 17 | 18 | Defined in file:///mod.ts:5:1 19 | 20 | private namespace MyNamespace 21 | 22 | class MyInternal 23 | 24 | @internal 25 | 26 | 27 | # output.json 28 | [ 29 | { 30 | "name": "PrivateProp", 31 | "isDefault": false, 32 | "location": { 33 | "filename": "file:///mod.ts", 34 | "line": 3, 35 | "col": 0, 36 | "byteIndex": 105 37 | }, 38 | "declarationKind": "export", 39 | "jsDoc": { 40 | "doc": "Comment" 41 | }, 42 | "kind": "typeAlias", 43 | "typeAliasDef": { 44 | "tsType": { 45 | "repr": "MyNamespace.MyInternal", 46 | "kind": "typeQuery", 47 | "typeQuery": "MyNamespace.MyInternal" 48 | }, 49 | "typeParams": [] 50 | } 51 | }, 52 | { 53 | "name": "MyNamespace", 54 | "isDefault": false, 55 | "location": { 56 | "filename": "file:///mod.ts", 57 | "line": 5, 58 | "col": 0, 59 | "byteIndex": 163 60 | }, 61 | "declarationKind": "private", 62 | "kind": "namespace", 63 | "namespaceDef": { 64 | "elements": [ 65 | { 66 | "name": "MyInternal", 67 | "isDefault": false, 68 | "location": { 69 | "filename": "file:///mod.ts", 70 | "line": 7, 71 | "col": 2, 72 | "byteIndex": 208 73 | }, 74 | "declarationKind": "export", 75 | "jsDoc": { 76 | "tags": [ 77 | { 78 | "kind": "internal" 79 | } 80 | ] 81 | }, 82 | "kind": "class", 83 | "classDef": { 84 | "isAbstract": false, 85 | "constructors": [], 86 | "properties": [], 87 | "indexSignatures": [], 88 | "methods": [], 89 | "extends": null, 90 | "implements": [], 91 | "typeParams": [], 92 | "superTypeParams": [] 93 | } 94 | } 95 | ] 96 | } 97 | } 98 | ] 99 | -------------------------------------------------------------------------------- /tests/specs/re_export_all.txt: -------------------------------------------------------------------------------- 1 | # a.ts 2 | const test1: string = ""; 3 | const test2: number = 3, test3: number = 3; 4 | const test4: number; 5 | const test5: number; 6 | 7 | export { test1, test2, test3 }; 8 | export { test4, test5 }; 9 | 10 | # b.ts 11 | export class Test {} 12 | 13 | # c.ts 14 | export * from "./a.ts"; 15 | export { Test } from "./b.ts"; 16 | 17 | # mod.ts 18 | export { Test, test1 } from "./c.ts"; 19 | 20 | # diagnostics 21 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 22 | --> /b.ts:1:1 23 | | 24 | 1 | export class Test {} 25 | | ^ 26 | 27 | 28 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 29 | --> /a.ts:1:7 30 | | 31 | 1 | const test1: string = ""; 32 | | ^ 33 | 34 | # output.txt 35 | Defined in file:///a.ts:1:7 36 | 37 | const test1: string 38 | 39 | Defined in file:///b.ts:1:1 40 | 41 | class Test 42 | 43 | 44 | 45 | # output.json 46 | [ 47 | { 48 | "name": "Test", 49 | "isDefault": false, 50 | "location": { 51 | "filename": "file:///b.ts", 52 | "line": 1, 53 | "col": 0, 54 | "byteIndex": 0 55 | }, 56 | "declarationKind": "export", 57 | "kind": "class", 58 | "classDef": { 59 | "isAbstract": false, 60 | "constructors": [], 61 | "properties": [], 62 | "indexSignatures": [], 63 | "methods": [], 64 | "extends": null, 65 | "implements": [], 66 | "typeParams": [], 67 | "superTypeParams": [] 68 | } 69 | }, 70 | { 71 | "name": "test1", 72 | "isDefault": false, 73 | "location": { 74 | "filename": "file:///a.ts", 75 | "line": 1, 76 | "col": 6, 77 | "byteIndex": 6 78 | }, 79 | "declarationKind": "export", 80 | "kind": "variable", 81 | "variableDef": { 82 | "tsType": { 83 | "repr": "string", 84 | "kind": "keyword", 85 | "keyword": "string" 86 | }, 87 | "kind": "const" 88 | } 89 | } 90 | ] 91 | -------------------------------------------------------------------------------- /tests/specs/reexport_existing_export.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(): void {} 3 | export { foo as bar }; 4 | 5 | # diagnostics 6 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 7 | --> /mod.ts:1:1 8 | | 9 | 1 | export function foo(): void {} 10 | | ^ 11 | 12 | # output.txt 13 | Defined in file:///mod.ts:1:1 14 | 15 | function bar(): void 16 | 17 | Defined in file:///mod.ts:1:1 18 | 19 | function foo(): void 20 | 21 | 22 | # output.json 23 | [ 24 | { 25 | "name": "foo", 26 | "isDefault": false, 27 | "location": { 28 | "filename": "file:///mod.ts", 29 | "line": 1, 30 | "col": 0, 31 | "byteIndex": 0 32 | }, 33 | "declarationKind": "export", 34 | "kind": "function", 35 | "functionDef": { 36 | "params": [], 37 | "returnType": { 38 | "repr": "void", 39 | "kind": "keyword", 40 | "keyword": "void" 41 | }, 42 | "hasBody": true, 43 | "isAsync": false, 44 | "isGenerator": false, 45 | "typeParams": [] 46 | } 47 | }, 48 | { 49 | "name": "bar", 50 | "isDefault": false, 51 | "location": { 52 | "filename": "file:///mod.ts", 53 | "line": 1, 54 | "col": 0, 55 | "byteIndex": 0 56 | }, 57 | "declarationKind": "export", 58 | "kind": "function", 59 | "functionDef": { 60 | "params": [], 61 | "returnType": { 62 | "repr": "void", 63 | "kind": "keyword", 64 | "keyword": "void" 65 | }, 66 | "hasBody": true, 67 | "isAsync": false, 68 | "isGenerator": false, 69 | "typeParams": [] 70 | } 71 | } 72 | ] 73 | -------------------------------------------------------------------------------- /tests/specs/ts_template_with_args.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export const tpl: `test${number}` = `test1`; 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:14 7 | | 8 | 1 | export const tpl: `test${number}` = `test1`; 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:14 13 | 14 | const tpl: `test${number}` 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "tpl", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 13, 26 | "byteIndex": 13 27 | }, 28 | "declarationKind": "export", 29 | "kind": "variable", 30 | "variableDef": { 31 | "tsType": { 32 | "repr": "test${number}", 33 | "kind": "literal", 34 | "literal": { 35 | "kind": "template", 36 | "tsTypes": [ 37 | { 38 | "repr": "test", 39 | "kind": "literal", 40 | "literal": { 41 | "kind": "string", 42 | "string": "test" 43 | } 44 | }, 45 | { 46 | "repr": "number", 47 | "kind": "keyword", 48 | "keyword": "number" 49 | }, 50 | { 51 | "repr": "", 52 | "kind": "literal", 53 | "literal": { 54 | "kind": "string", 55 | "string": "" 56 | } 57 | } 58 | ] 59 | } 60 | }, 61 | "kind": "const" 62 | } 63 | } 64 | ] 65 | -------------------------------------------------------------------------------- /tests/specs/ts_type_assertion.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(bar: any): asserts bar {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function foo(bar: any): asserts bar {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function foo(bar: any): asserts bar 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "foo", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "identifier", 34 | "name": "bar", 35 | "optional": false, 36 | "tsType": { 37 | "repr": "any", 38 | "kind": "keyword", 39 | "keyword": "any" 40 | } 41 | } 42 | ], 43 | "returnType": { 44 | "repr": "asserts bar", 45 | "kind": "typePredicate", 46 | "typePredicate": { 47 | "asserts": true, 48 | "param": { 49 | "type": "identifier", 50 | "name": "bar" 51 | }, 52 | "type": null 53 | } 54 | }, 55 | "hasBody": true, 56 | "isAsync": false, 57 | "isGenerator": false, 58 | "typeParams": [] 59 | } 60 | } 61 | ] 62 | -------------------------------------------------------------------------------- /tests/specs/ts_type_predicate1.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(bar: A | B): bar is A {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function foo(bar: A | B): bar is A {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function foo(bar: A | B): bar is A 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "foo", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "identifier", 34 | "name": "bar", 35 | "optional": false, 36 | "tsType": { 37 | "repr": "", 38 | "kind": "union", 39 | "union": [ 40 | { 41 | "repr": "A", 42 | "kind": "typeRef", 43 | "typeRef": { 44 | "typeParams": null, 45 | "typeName": "A" 46 | } 47 | }, 48 | { 49 | "repr": "B", 50 | "kind": "typeRef", 51 | "typeRef": { 52 | "typeParams": null, 53 | "typeName": "B" 54 | } 55 | } 56 | ] 57 | } 58 | } 59 | ], 60 | "returnType": { 61 | "repr": "bar is A", 62 | "kind": "typePredicate", 63 | "typePredicate": { 64 | "asserts": false, 65 | "param": { 66 | "type": "identifier", 67 | "name": "bar" 68 | }, 69 | "type": { 70 | "repr": "A", 71 | "kind": "typeRef", 72 | "typeRef": { 73 | "typeParams": null, 74 | "typeName": "A" 75 | } 76 | } 77 | } 78 | }, 79 | "hasBody": true, 80 | "isAsync": false, 81 | "isGenerator": false, 82 | "typeParams": [] 83 | } 84 | } 85 | ] 86 | -------------------------------------------------------------------------------- /tests/specs/ts_type_predicate2.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function foo(bar: A | B): asserts bar is B {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function foo(bar: A | B): asserts bar is B {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function foo(bar: A | B): asserts bar is B 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "foo", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "identifier", 34 | "name": "bar", 35 | "optional": false, 36 | "tsType": { 37 | "repr": "", 38 | "kind": "union", 39 | "union": [ 40 | { 41 | "repr": "A", 42 | "kind": "typeRef", 43 | "typeRef": { 44 | "typeParams": null, 45 | "typeName": "A" 46 | } 47 | }, 48 | { 49 | "repr": "B", 50 | "kind": "typeRef", 51 | "typeRef": { 52 | "typeParams": null, 53 | "typeName": "B" 54 | } 55 | } 56 | ] 57 | } 58 | } 59 | ], 60 | "returnType": { 61 | "repr": "asserts bar is B", 62 | "kind": "typePredicate", 63 | "typePredicate": { 64 | "asserts": true, 65 | "param": { 66 | "type": "identifier", 67 | "name": "bar" 68 | }, 69 | "type": { 70 | "repr": "B", 71 | "kind": "typeRef", 72 | "typeRef": { 73 | "typeParams": null, 74 | "typeName": "B" 75 | } 76 | } 77 | } 78 | }, 79 | "hasBody": true, 80 | "isAsync": false, 81 | "isGenerator": false, 82 | "typeParams": [] 83 | } 84 | } 85 | ] 86 | -------------------------------------------------------------------------------- /tests/specs/ts_type_predicate3.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export class C { 3 | isSomething(): this is Something {} 4 | } 5 | 6 | # diagnostics 7 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 8 | --> /mod.ts:1:1 9 | | 10 | 1 | export class C { 11 | | ^ 12 | 13 | 14 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 15 | --> /mod.ts:2:3 16 | | 17 | 2 | isSomething(): this is Something {} 18 | | ^ 19 | 20 | # output.txt 21 | Defined in file:///mod.ts:1:1 22 | 23 | class C 24 | 25 | isSomething(): this is Something 26 | 27 | 28 | # output.json 29 | [ 30 | { 31 | "name": "C", 32 | "isDefault": false, 33 | "location": { 34 | "filename": "file:///mod.ts", 35 | "line": 1, 36 | "col": 0, 37 | "byteIndex": 0 38 | }, 39 | "declarationKind": "export", 40 | "kind": "class", 41 | "classDef": { 42 | "isAbstract": false, 43 | "constructors": [], 44 | "properties": [], 45 | "indexSignatures": [], 46 | "methods": [ 47 | { 48 | "accessibility": null, 49 | "optional": false, 50 | "isAbstract": false, 51 | "isStatic": false, 52 | "name": "isSomething", 53 | "kind": "method", 54 | "functionDef": { 55 | "params": [], 56 | "returnType": { 57 | "repr": "this is Something", 58 | "kind": "typePredicate", 59 | "typePredicate": { 60 | "asserts": false, 61 | "param": { 62 | "type": "this" 63 | }, 64 | "type": { 65 | "repr": "Something", 66 | "kind": "typeRef", 67 | "typeRef": { 68 | "typeParams": null, 69 | "typeName": "Something" 70 | } 71 | } 72 | } 73 | }, 74 | "hasBody": true, 75 | "isAsync": false, 76 | "isGenerator": false, 77 | "typeParams": [] 78 | }, 79 | "location": { 80 | "filename": "file:///mod.ts", 81 | "line": 2, 82 | "col": 2, 83 | "byteIndex": 19 84 | } 85 | } 86 | ], 87 | "extends": null, 88 | "implements": [], 89 | "typeParams": [], 90 | "superTypeParams": [] 91 | } 92 | } 93 | ] 94 | -------------------------------------------------------------------------------- /tests/specs/type_alias.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type A = number 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type A = number 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type A = number 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "A", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "number", 33 | "kind": "keyword", 34 | "keyword": "number" 35 | }, 36 | "typeParams": [] 37 | } 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /tests/specs/type_alias_infer_type.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type Flatten = T extends Array ? U : T; 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type Flatten = T extends Array ? U : T; 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type Flatten = T extends Array ? U : T 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "Flatten", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "conditional", 34 | "conditionalType": { 35 | "checkType": { 36 | "repr": "T", 37 | "kind": "typeRef", 38 | "typeRef": { 39 | "typeParams": null, 40 | "typeName": "T" 41 | } 42 | }, 43 | "extendsType": { 44 | "repr": "Array", 45 | "kind": "typeRef", 46 | "typeRef": { 47 | "typeParams": [ 48 | { 49 | "repr": "", 50 | "kind": "infer", 51 | "infer": { 52 | "typeParam": { 53 | "name": "U" 54 | } 55 | } 56 | } 57 | ], 58 | "typeName": "Array" 59 | } 60 | }, 61 | "trueType": { 62 | "repr": "U", 63 | "kind": "typeRef", 64 | "typeRef": { 65 | "typeParams": null, 66 | "typeName": "U" 67 | } 68 | }, 69 | "falseType": { 70 | "repr": "T", 71 | "kind": "typeRef", 72 | "typeRef": { 73 | "typeParams": null, 74 | "typeName": "T" 75 | } 76 | } 77 | } 78 | }, 79 | "typeParams": [ 80 | { 81 | "name": "T" 82 | } 83 | ] 84 | } 85 | } 86 | ] 87 | -------------------------------------------------------------------------------- /tests/specs/type_generic_alias.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type A = T 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type A = T 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type A = T 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "A", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "T", 33 | "kind": "typeRef", 34 | "typeRef": { 35 | "typeParams": null, 36 | "typeName": "T" 37 | } 38 | }, 39 | "typeParams": [ 40 | { 41 | "name": "T" 42 | } 43 | ] 44 | } 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /tests/specs/type_import_type.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export function adopt(p: import("./module.ts").Pet) { } 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export function adopt(p: import("./module.ts").Pet) { } 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | function adopt(p: import("./module.ts").Pet): void 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "adopt", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "function", 30 | "functionDef": { 31 | "params": [ 32 | { 33 | "kind": "identifier", 34 | "name": "p", 35 | "optional": false, 36 | "tsType": { 37 | "repr": "", 38 | "kind": "importType", 39 | "importType": { 40 | "specifier": "./module.ts", 41 | "qualifier": "Pet", 42 | "typeParams": [ 43 | { 44 | "repr": "T", 45 | "kind": "typeRef", 46 | "typeRef": { 47 | "typeParams": null, 48 | "typeName": "T" 49 | } 50 | } 51 | ] 52 | } 53 | } 54 | } 55 | ], 56 | "returnType": { 57 | "repr": "void", 58 | "kind": "keyword", 59 | "keyword": "void" 60 | }, 61 | "hasBody": true, 62 | "isAsync": false, 63 | "isGenerator": false, 64 | "typeParams": [ 65 | { 66 | "name": "T" 67 | } 68 | ] 69 | } 70 | } 71 | ] 72 | -------------------------------------------------------------------------------- /tests/specs/type_literal_declaration.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type T = {} 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type T = {} 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type T = { } 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "T", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "typeLiteral", 34 | "typeLiteral": { 35 | "constructors": [], 36 | "methods": [], 37 | "properties": [], 38 | "callSignatures": [], 39 | "indexSignatures": [] 40 | } 41 | }, 42 | "typeParams": [] 43 | } 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /tests/specs/type_literal_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type T = { [key: string]: number; } 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type T = { [key: string]: number; } 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type T = { [key: string]: number; } 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "T", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "typeLiteral", 34 | "typeLiteral": { 35 | "constructors": [], 36 | "methods": [], 37 | "properties": [], 38 | "callSignatures": [], 39 | "indexSignatures": [ 40 | { 41 | "readonly": false, 42 | "params": [ 43 | { 44 | "kind": "identifier", 45 | "name": "key", 46 | "optional": false, 47 | "tsType": { 48 | "repr": "string", 49 | "kind": "keyword", 50 | "keyword": "string" 51 | } 52 | } 53 | ], 54 | "tsType": { 55 | "repr": "number", 56 | "kind": "keyword", 57 | "keyword": "number" 58 | }, 59 | "location": { 60 | "filename": "file:///mod.ts", 61 | "line": 1, 62 | "col": 18, 63 | "byteIndex": 18 64 | } 65 | } 66 | ] 67 | } 68 | }, 69 | "typeParams": [] 70 | } 71 | } 72 | ] 73 | -------------------------------------------------------------------------------- /tests/specs/type_literal_mapped_type.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type T = { readonly [P in keyof Type as NewType]: Type[P]; } 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type T = { readonly [P in keyof Type as NewType]: Type[P]; } 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type T = readonly [P in keyof Type as NewType]: Type[P] 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "T", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "mapped", 34 | "mappedType": { 35 | "readonly": true, 36 | "typeParam": { 37 | "name": "P", 38 | "constraint": { 39 | "repr": "", 40 | "kind": "typeOperator", 41 | "typeOperator": { 42 | "operator": "keyof", 43 | "tsType": { 44 | "repr": "Type", 45 | "kind": "typeRef", 46 | "typeRef": { 47 | "typeParams": null, 48 | "typeName": "Type" 49 | } 50 | } 51 | } 52 | } 53 | }, 54 | "nameType": { 55 | "repr": "NewType", 56 | "kind": "typeRef", 57 | "typeRef": { 58 | "typeParams": null, 59 | "typeName": "NewType" 60 | } 61 | }, 62 | "tsType": { 63 | "repr": "", 64 | "kind": "indexedAccess", 65 | "indexedAccess": { 66 | "readonly": false, 67 | "objType": { 68 | "repr": "Type", 69 | "kind": "typeRef", 70 | "typeRef": { 71 | "typeParams": null, 72 | "typeName": "Type" 73 | } 74 | }, 75 | "indexType": { 76 | "repr": "P", 77 | "kind": "typeRef", 78 | "typeRef": { 79 | "typeParams": null, 80 | "typeName": "P" 81 | } 82 | } 83 | } 84 | } 85 | } 86 | }, 87 | "typeParams": [ 88 | { 89 | "name": "Type" 90 | } 91 | ] 92 | } 93 | } 94 | ] 95 | -------------------------------------------------------------------------------- /tests/specs/type_literal_readonly_index_signature.txt: -------------------------------------------------------------------------------- 1 | # mod.ts 2 | export type T = { readonly [key: string]: number; } 3 | 4 | # diagnostics 5 | error[missing-jsdoc]: exported symbol is missing JSDoc documentation 6 | --> /mod.ts:1:1 7 | | 8 | 1 | export type T = { readonly [key: string]: number; } 9 | | ^ 10 | 11 | # output.txt 12 | Defined in file:///mod.ts:1:1 13 | 14 | type T = { readonly [key: string]: number; } 15 | 16 | 17 | # output.json 18 | [ 19 | { 20 | "name": "T", 21 | "isDefault": false, 22 | "location": { 23 | "filename": "file:///mod.ts", 24 | "line": 1, 25 | "col": 0, 26 | "byteIndex": 0 27 | }, 28 | "declarationKind": "export", 29 | "kind": "typeAlias", 30 | "typeAliasDef": { 31 | "tsType": { 32 | "repr": "", 33 | "kind": "typeLiteral", 34 | "typeLiteral": { 35 | "constructors": [], 36 | "methods": [], 37 | "properties": [], 38 | "callSignatures": [], 39 | "indexSignatures": [ 40 | { 41 | "readonly": true, 42 | "params": [ 43 | { 44 | "kind": "identifier", 45 | "name": "key", 46 | "optional": false, 47 | "tsType": { 48 | "repr": "string", 49 | "kind": "keyword", 50 | "keyword": "string" 51 | } 52 | } 53 | ], 54 | "tsType": { 55 | "repr": "number", 56 | "kind": "keyword", 57 | "keyword": "number" 58 | }, 59 | "location": { 60 | "filename": "file:///mod.ts", 61 | "line": 1, 62 | "col": 18, 63 | "byteIndex": 18 64 | } 65 | } 66 | ] 67 | } 68 | }, 69 | "typeParams": [] 70 | } 71 | } 72 | ] 73 | -------------------------------------------------------------------------------- /tests/testdata/dts/a.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2025 the Deno authors. MIT license. 2 | 3 | /// 4 | /// 5 | 6 | interface WebSocket { 7 | readonly bufferedAmount: number; 8 | } 9 | 10 | declare var WebSocket: { 11 | readonly prototype: WebSocket; 12 | new (url: string, protocols?: string | string[]): WebSocket; 13 | readonly OPEN: number; 14 | }; 15 | 16 | interface ResponseInit { 17 | status?: number; 18 | statusText?: string; 19 | } 20 | -------------------------------------------------------------------------------- /tests/testdata/multiple/_d.ts: -------------------------------------------------------------------------------- 1 | export function externalFunction(_n = 0) {} 2 | -------------------------------------------------------------------------------- /tests/testdata/multiple/b.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module bar 3 | */ 4 | 5 | export function x(_n = 0) {} 6 | 7 | /** The default export item. 8 | * 9 | * This item reproduces the issue reported in {@link https://github.com/jsr-io/jsr/issues/459} 10 | */ 11 | const default_: number = 0; 12 | export { default_ as default }; 13 | -------------------------------------------------------------------------------- /tests/testdata/multiple/c.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module c 3 | */ 4 | 5 | export function x(_n = 0) {} 6 | -------------------------------------------------------------------------------- /tests/testdata/single/a.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * ```ts 3 | * using time = new FakeTime(); 4 | * ``` 5 | */ 6 | export class Foo {} 7 | 8 | export class Bar extends Foo {} 9 | 10 | // deno-lint-ignore no-empty-interface 11 | interface NotExported {} 12 | 13 | export default class Foobar {} 14 | --------------------------------------------------------------------------------