Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deno doc --lint #21032

Merged
merged 8 commits into from
Oct 31, 2023
Merged

feat: deno doc --lint #21032

merged 8 commits into from
Oct 31, 2023

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Oct 31, 2023

Adds a new --lint flag to deno doc that surfaces three kinds of diagnostics:

  1. Diagnostic for non-exported type referenced in an exported type.
    • Why? People often forget to export types from a module in TypeScript. To supress this diagnostic, add an @internal jsdoc tag to the internal type.
  2. Diagnostic for missing return type or missing property type on a public type.
    • Why? Otherwise deno doc will not display good documentation. Adding explicit types also helps with type checking performance.
  3. Diagnostic for missing jsdoc on a public type.
    • Why? Everything should be documented. This diagnostic can be supressed by adding a jsdoc comment description.

If the lint passes, deno doc generates documentation as usual.

For example, checking for deno doc diagnostics on the CI:

$ deno doc --lint mod.ts second_entrypoint.ts > /dev/null

This feature is incredibly useful for library authors.

Why not include this in deno lint?

  1. The command needs the documenation output in order to figure out the diagnostics.
  2. deno lint doesn't understand where the entrypoints are. That's critical for the diagnostics to be useful.
  3. It's much more performant to do this while generating documentation.
  4. There is precedence in rustdoc (ex. #![warn(missing_docs)]).

Why not --check?

It is confusing with deno run --check, since that means to run type checking (and confusing with deno check --docs).

Output Future Improvement

The output is not ideal atm, but it's fine for a first pass. We will improve it in the future.

Closes denoland/deno_lint#972
Closes denoland/deno_lint#970
Closes #19356

@dsherret dsherret requested a review from bartlomieju October 31, 2023 18:44
dsherret and others added 2 commits October 31, 2023 14:48
Signed-off-by: David Sherret <dsherret@users.noreply.github.com>
@iuioiua
Copy link
Contributor

iuioiua commented Oct 31, 2023

This is great! It'll definitely help those with projects that aim to be high-quality 💪🏾

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@dsherret
Copy link
Member Author

There are some improvements in deno_doc that will make this better, but going to merge this for now.

@dsherret dsherret merged commit d1ef561 into denoland:main Oct 31, 2023
@dsherret dsherret deleted the deno_doc_diagnostics branch October 31, 2023 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants