Skip to content

feat: read tsdoc.json and check TSDoc's grammar - #40

Open
botandbang wants to merge 5 commits into
bnb/tsdocfrom
bnb/tsdoc-config
Open

botandbang wants to merge 5 commits into
bnb/tsdocfrom
bnb/tsdoc-config

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

docov now reads a project's tsdoc.json and checks doc comments against TSDoc's grammar, reporting what @microsoft/tsdoc reports, with the same message ids and texts, so findings line up with eslint-plugin-tsdoc.

Added: a tsdocConfig key and --tsdoc-config flag (src/feature/tsdoc_config.rs). With "syntax": "tsdoc" and neither set, each file is read with the tsdoc.json @microsoft/tsdoc-config would find for it: the one in the nearest folder above the file with a tsconfig.json or a package.json. A tsdoc.json can extend files by path or package name, resolved with oxc_resolver, and docov reads noStandardTags, tagDefinitions, supportForTags, supportedHtmlElements and reportUnsupportedHtmlElements the way tsdoc-config sets up the parser. Unknown keys and other mistakes exit 2 with TSDoc's tsdoc-config-* ids.

Added: src/tsdoc/, a Rust port of @microsoft/tsdoc's parser that keeps its messages and positions and skips the node tree. Running the package through Node would have made the cargo install and the language server depend on Node, and nothing on crates.io parses TSDoc's grammar.

Added: seven doc checks, one per part of the grammar: tsdoc-tags (undefined, unsupported or misused tags, @deprecated without a message, {@inheritDoc} rules, plus two docov-only findings TSDoc has no check for: a tag repeated without allowMultiple and text after a modifier tag), tsdoc-params, tsdoc-inline-tags, tsdoc-escapes, tsdoc-code, tsdoc-html and tsdoc-links. The tsdoc.json lookup runs only when one of them is on.

Added: tools/tsdoc-oracle.sh and tests/fixtures/tsdoc/corpus.json. The script runs @microsoft/tsdoc 0.17.1 over 260 comments, 75 of them from its own parser tests, and records what it finds. A unit test and a Hegel property check docov against that file, along with properties for tsdoc.json loading and errors, the per-file lookup through the CLI, and the two docov-only findings. There are also failing and passing examples under tests/fixtures/checks/ for the generated check docs.

Changed: @remarks {@inheritDoc} in tests/fixtures/tsdoc/parser.ts became {@inheritDoc}, since TSDoc rejects @remarks next to {@inheritDoc}. The collect unit tests' helper leaves out the tsdoc-* checks, which have their own tests. The README lists the new checks, and docov.schema.json describes the key and the checks.

Closes #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant