-
Notifications
You must be signed in to change notification settings - Fork 583
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
Add yamllint check for RST code listings #2385
base: devel
Are you sure you want to change the base?
Conversation
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.
Have you considered using sphinxawesome-codelinter
? Their README has yamllint as an example: https://github.com/kai687/sphinxawesome-codelinter?tab=readme-ov-file#configure.
I haven't because I wasn't aware of it. Looking at it, I also think it would perform worse than the code in this PR:
|
14ad397
to
927eb2b
Compare
Currently contains #2408. Will rebase once that's merged. |
927eb2b
to
65df3b8
Compare
e3a33f8
to
557b3f4
Compare
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.
@felixfontein Looks really good to me. I had a couple minor suggestions on warnings. Other than that I think it's great. Maybe we could add some docstrings to classes to improve things further.
Thanks very much for working on this!
Might be worth contributing this code there then? |
tests/checkers/rst-yamllint.py
Outdated
"path": self.__path, | ||
"line": node.line or "unknown", | ||
"col": 0, | ||
"message": f"Warning: found unknown literal block! Check for double colons '::'. If that is not the cause, please report this warning. It might indicate a bug in the checker or an unsupported Sphinx directive. Node: {node!r}; attributes: {node.attributes}; content: {node.rawsource!r}", |
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.
"message": f"Warning: found unknown literal block! Check for double colons '::'. If that is not the cause, please report this warning. It might indicate a bug in the checker or an unsupported Sphinx directive. Node: {node!r}; attributes: {node.attributes}; content: {node.rawsource!r}", | |
"message": f"Warning: found unknown literal block! Check for double colons '::' and convert them to code blocks. If that is not the cause, please report this warning. It might indicate a bug in the checker or an unsupported Sphinx directive. Node: {node!r}; attributes: {node.attributes}; content: {node.rawsource!r}", |
@oraNod ^ is that better?
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.
Ah, right. It's implicit code blocks (I guess that's the right way to say it). I forgot you could just have naked ::
double colons. Anyway this looks like a good improvement to me.
Definitely. I don't think I have time for that anytime soon, though... |
I've also made sure that regular YAML files in the repository pass |
I think the current scope is good, just the Maybe the only thing really missing is an entry in the README to explain how folks can use the checkers test to verify their changes as part of a PR? https://github.com/ansible/ansible-documentation/blob/devel/README.md#running-automated-tests |
In a typical Python project, I'd have it as a part of the pre-commit config. Here, it might make sense to add it to |
@@ -1,7 +1,7 @@ | |||
--- | |||
|
|||
name: Ansible package docs build | |||
on: | |||
"on": |
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.
FWIW, dropping a config like https://github.com/ansible/awx-plugins/blob/e5f7468/.yamllint into the repo would allow these.
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.
Generally enabling on
just for a handful of special YAML files sounds like a bad idea.
Ack. I just realized I'd love to use this elsewhere myself. |
Either it needs a new session, with new lock files, or an existing session needs to be extended (with new requirements). (Neither is anything I want to do in this PR.)
It's already there. |
Co-authored-by: Don Naro <[email protected]>
3b7d1cc
to
564d3e0
Compare
Are you talking about this repo? I don't see it. |
This uses a third-party Sphinx extension now [[1]]. In the future, though, we should explore using the solution from ansible-documentation [[2]]. [1]: https://github.com/kai687/sphinxawesome-codelinter [2]: ansible/ansible-documentation#2385
This uses a third-party Sphinx extension now [[1]]. In the future, though, we should explore using the solution from ansible-documentation [[2]]. [1]: https://github.com/kai687/sphinxawesome-codelinter [2]: ansible/ansible-documentation#2385
Oh, I thought you were talking about something pre-existing :) Thanks for pointing this out! |
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.
Maybe some of the more experienced Pythonistas around here will have more feedback, but this looks really solid to me.
Thanks for doing this @felixfontein It's a great improvement to the quality of the docs.
This was harder than I expected since the line number information is bonkers
literal_block
nodes, and the column information not there completely.This currently fails in quite a few places. Once #2382 is merged this should get better though...Also I currently disabled most problems - we also have to figure out the config we want to use. I guess the most pressing issues are syntax errors when it's simply not a YAML file at all ;)
Ref: #2382 (comment)