Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

[docs] Generate linting docs from source #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jugglinmike
Copy link
Member

When new rules have been added to WPT's "lint" tool, the corresponding
documentation has not always been updated [1] [2] [3]. Automatically
generating documentation from source code helps avoid this state and the
confusion it can cause contributors.

Introduce a pattern for defining linting rules. Rely on the new
structure during documentation generation to automatically create a
listing of all available linting rules.

The new structure centralizes information about the rules (name,
description, and instructions for correcting infractions). The process
honors the existing convention of Markdown within descriptions.

Although the Sphinx documentation generator includes a built-in
extension for generating documentation from Python source code, the
output of that extension is designed to document Python primitives such
as functions and classes. Such a format is inappropriate for this case
because the users of the linting tool do not interact with the internals
in this way. Define a custom docutils directive to tailor the
documentation to the needs of its audience.

[1] web-platform-tests/wpt#5299
[2] web-platform-tests/wpt#10501
[3] web-platform-tests/wpt#11479


This is intended to resolve gh-4.

@zcorpan @jgraham @gsnedders @marcoscaceres I'm demoing this with two rules,
but I'll be happy to migrate the rest of the rules to this format if the
general solution looks good to you. Here's a screen shot of the rendered
output:

2019-03-29-linting-docs

What do you think?

When new rules have been added to WPT's "lint" tool, the corresponding
documentation has not always been updated [1] [2] [3]. Automatically
generating documentation from source code helps avoid this state and the
confusion it can cause contributors.

Introduce a pattern for defining linting rules. Rely on the new
structure during documentation generation to automatically create a
listing of all available linting rules.

The new structure centralizes information about the rules (name,
description, and instructions for correcting infractions). The process
honors the existing convention of Markdown within descriptions.

Although the Sphinx documentation generator includes a built-in
extension for generating documentation from Python source code, the
output of that extension is designed to document Python primitives such
as functions and classes. Such a format is inappropriate for this case
because the users of the linting tool do not interact with the internals
in this way. Define a custom docutils directive to tailor the
documentation to the needs of its audience.

[1] web-platform-tests/wpt#5299
[2] web-platform-tests/wpt#10501
[3] web-platform-tests/wpt#11479
@zcorpan
Copy link
Contributor

zcorpan commented Mar 29, 2019

I think this is a good approach 👍

It looks like lint/tests/test_file_lints.py may need to be changed as part of this.

@marcoscaceres
Copy link
Contributor

marcoscaceres commented Apr 1, 2019 via email

@jgraham
Copy link
Contributor

jgraham commented Apr 1, 2019

This approach looks good. Please endeavour to land the lint changes upstream rather than in a docs branch, even if the motivating documentation isn't ready yet, otherwise there's a severe chance of conflicts which in this case would likely lead to regressing whole lint rules.

@jugglinmike
Copy link
Member Author

Sure thing, @jgraham. Here's a patch that's scoped to the linter's source code:

web-platform-tests/wpt#16268

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discourage rot in linting documentation
4 participants