-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
validate-modules: add support for semantic markup #80243
validate-modules: add support for semantic markup #80243
Conversation
#80244 is the subset of this PR that only handles the |
e3014c6
to
5e942d9
Compare
Note that this is essentially doing the same as ansible-community/antsibull-docs#112. |
I'm wondering whether it isn't better to not actually add this here, but instead have |
for m in _UNESCAPE.finditer(content): | ||
if m.group(1) not in ('\\', ')'): | ||
raise _add_ansible_error_code( | ||
Invalid('Directive "%s" contains unnecessarily quoted "%s"' % (directive, m.group(1))), |
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 believe it would be more accurate to refer to the use of \
as "escaped" instead of "quoted", as is done in the Python documentation. It should be updated in various places in this PR and in #80240.
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.
_CONTENT_LINK_SPLITTER_RE = re.compile(r'(?:\[[^\]]*\])?\.') | ||
_CONTENT_LINK_END_STUB_RE = re.compile(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.
These contain unnecessary escapes:
_CONTENT_LINK_SPLITTER_RE = re.compile(r'(?:\[[^\]]*\])?\.') | |
_CONTENT_LINK_END_STUB_RE = re.compile(r'\[[^\]]*\]$') | |
_CONTENT_LINK_SPLITTER_RE = re.compile(r'(?:\[[^]]*])?\.') | |
_CONTENT_LINK_END_STUB_RE = re.compile(r'\[[^]]*]$') |
a7=dict(), | ||
a8=dict(), | ||
a9=dict(), | ||
a10=dict(), |
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.
There are no tests for suboptions here.
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 added suboption tests in #80383.
_IGNORE_MARKER = 'ignore:' | ||
_IGNORE_STRING = '(ignore)' | ||
|
||
_VALID_PLUGIN_TYPES = set(DOCUMENTABLE_PLUGINS) |
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.
Does this intentionally omit support for the role
type as described in #80240?
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.
No, this PR hasn't been updated for roles support yet (that's why I marked it as a draft).
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.
#80383 also supports roles.
I think it makes sense to have this validation in core, to avoid issues with invalid semantic markup in core plugins. |
I've been thinking about removing the explicit markup validation code from this PR and instead of using the antsibull-docs-parser (https://github.com/ansible-community/antsibull-docs-parser) library. (It has zero dependencies, the idea is that other projects can use it for markup processing.) |
So you'd maintain the same functionality as already exists in this PR, but offload some of the implementation to that library? |
Yes; only the markup parsing / validation itself will be offloaded. Right now that part is basically implemented five times (here, ansible-doc in a simplified version, antsibull-docs, antsibull-docs-parser, and antsibull-docs-ts) - my goal is to trim this down to at most three different implementations (ansible-doc probably needs its own to not depend on another library; antsibull-docs-parser for the generic Python implementation; and antsibull-docs-ts for the generic TypeScript implementation). |
@felixfontein Since ansible-doc and validate-modules will both need it, why not just vendor the library in the ansible repo so they can both use the same code? |
@felixfontein Do you think it would be reasonable to merge this as-is before freeze, and then follow-up with the vendoring as a bug fix before the release? That would also take care of the missing role support. |
@mattclay IMO that would be fine! I won't have time to do anything on this today or tomorrow, but I can create a follow-up 'bugfix' next week. |
@felixfontein That works for me. If you're ready for this to be merged, just mark it as ready for review. The minor issues I mentioned in my review comments can be addressed in your follow-up PR. |
@mattclay done |
#80383 contains the follow-up PR which replaces the parsing/rendering code with code from antsibull-docs-parser. |
SUMMARY
Subset of #74937 which adds semantic markup support to validate-modules.
ISSUE TYPE
COMPONENT NAME
validate-modules