-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add tools for documentation formatting and validation #8136
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
base: main
Are you sure you want to change the base?
Conversation
Status as-of dddad32 SpellingCurrently the spelling plugin is installed and working with There are some quirks with it
flake8It looks like flake8-rst-docstrings and flake8-docstrings are already on the pre-commit dependencies, just need to make sure they're running blacken-docsSo far I like this one a lot. One note is that it only runs in It doesn't pick up the .. code:: pycon
>>> Base.metadata.create_all(engine)
"""{opensql}
...
CREATE TABLE user_account (
id INTEGER NOT NULL,
name VARCHAR(30) NOT NULL,
fullname VARCHAR,
PRIMARY KEY (id)
)
...
""" Probably pretty easy to change the identifiers, then the whole block stays as valid (formattable) python. Nice too that then rst syntax highlighters would pick it up. Side note: a
.. role:: python(code)
:language: python
.. role:: sql(code)
:language: sql |
Turns out I mixed up the flake8 things. Could also add doctest as a precommit hook. Interestingly, zzzeek was the inspiration for flake8-rst |
id have to look and see what the rationale for "pycon+sql" as a separate thing was. it's very old and lots of things have changed since then, including that I've ditched the [SQL] button thing which seemed so clever 15 years ago. also would need to see how blacken-docs formats python console examples. |
visitable | ||
walkthrough | ||
zxJDBC | ||
zxJDBC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - I'll dedupe before marking the PR as non-draft
# spelling_ignore_acronyms = True | ||
# spelling_ignore_python_builtins = True | ||
# spelling_ignore_importable_modules = True | ||
# spelling_ignore_contributor_names = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a configuration that indicates the location of the wordlist file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there's spelling_word_list_filename
, I just included the word filter related options. Do you want it to be explicit?
Full options here https://sphinxcontrib-spelling.readthedocs.io/en/latest/customize.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to make it explicit yes, so searching the file name would make it obvious where it's used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also a comment with the link to the option list is always handy :)
@zzzeek tested it out, it does about what you'd expect for pycon, just looks like standard black formatting. One note is it does remove blank lines in pycon, which are sometimes nice to have. I guess the correct solutions here would be to add a # on these blank lines, Did a quick test on the orm quickstart page to show how it formats. _test is the original file, _formatted is post blacken-docs. Had to zip the files because gh doesn't like rst, for no good reason |
these would be nice to have |
Heh, having fun testing the inline roles If you want to you could :mysql:`set @@system_versioning_alter_history = true`,
or if you feel like it :tsql:`USE sqlalchemy; GO`, or if you don't feel like it
:postgres:`SELECT 'i know my a b c's'::tsvector @@ 'a & b'::tsquery;`. Maybe
even :ccode:`++i; i++; printf("don't be fooled, they're different\n");`, but at
the end of the day you just want to :python:`print([relax for relax in paradise if
relax.temp_c < 28])`
Compared to unformatted ``SELECT 'i know my a b c'::tsvector @@ 'a &
b'::tsquery;`` I didn't even know they had sql flavor-specific highlighting, sqlalchemy is probably the best project possible to make use of that |
I'm hitting a bug running spelling on the changelogs, (report) so I just excluded that directory for now. There's also something zzzeeksphinx doesn't like, it does the spellcheck fine but throws an error at the end looking for some css/scss files in the That being said, it runs successfully for the most part and I have a semifinal word list done. A lot of the remaining errors are just unquoted code or variable names that use "" rather than ````. I notice that a ton of docs even backtick quote simple things like Excluding code quoting, looks like the docs are overall very good for spelling, probably only 100 or so errors. I think it would be good to merge this PR (when ready) without any fixes, then do a separate formatting PR that can be marked as ignore in .git-blame-ignore-revs. I don't think the flake8 checks will work now - I actually took over the flake8-rst repo from the old maintainer (think he just didn't have time) but it will take a bit of time before that is ready to go. So the main thing here is probably just deciding how to handle code blocks. Could also put the SQL in a collapsable section like this I guess https://stackoverflow.com/a/25543713/5380651, or do the docstring thing, or just leave those blocks unformatted. Additionally, I think I'd like to write some docs about writing docs, to help anyone new out (I struggled a bit getting started when I wrote the docs for the temporal thingy). Where's a good place for that? |
there's a lot happening here....spellcheck is nice but this seems like a lot of new tooling to deal with. any way we can have separate PRs for individual new checkers and such so we can just do small things one at a time? if there's no longer interest in working on this I'll close it for now. |
Description
The goal of this PR is to add tools that help with contributing to documentation, from discussion started on #7659. Goals include:
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>
in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>
in the commit messageHave a nice day!