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

validate-modules: add support for semantic markup #80243

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Subset of #74937 which adds semantic markup support to validate-modules.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

validate-modules

@ansibot ansibot added affects_2.15 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. new_plugin This PR includes a new plugin. test This PR relates to tests. labels Mar 16, 2023
@felixfontein
Copy link
Contributor Author

#80244 is the subset of this PR that only handles the seealso schema change.

@felixfontein felixfontein force-pushed the semantic-markup-ansible-test branch from e3014c6 to 5e942d9 Compare March 23, 2023 18:37
@felixfontein
Copy link
Contributor Author

Note that this is essentially doing the same as ansible-community/antsibull-docs#112.

@felixfontein
Copy link
Contributor Author

I'm wondering whether it isn't better to not actually add this here, but instead have antsibull-docs lint-collection-docs do such linting. Obviously one thing that isn't covered by that are the modules and plugins coming with ansible-core, though.

@felixfontein felixfontein marked this pull request as draft March 27, 2023 20:09
@ansibot ansibot added the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Mar 27, 2023
@mattclay mattclay mentioned this pull request Mar 30, 2023
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))),
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #80383, also in be68627.

Comment on lines +97 to +98
_CONTENT_LINK_SPLITTER_RE = re.compile(r'(?:\[[^\]]*\])?\.')
_CONTENT_LINK_END_STUB_RE = re.compile(r'\[[^\]]*\]$')
Copy link
Member

Choose a reason for hiding this comment

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

These contain unnecessary escapes:

Suggested change
_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(),
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#80383 also supports roles.

@mattclay
Copy link
Member

I'm wondering whether it isn't better to not actually add this here, but instead have antsibull-docs lint-collection-docs do such linting. Obviously one thing that isn't covered by that are the modules and plugins coming with ansible-core, though.

I think it makes sense to have this validation in core, to avoid issues with invalid semantic markup in core plugins.

@felixfontein
Copy link
Contributor Author

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.)

@mattclay
Copy link
Member

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?

@felixfontein
Copy link
Contributor Author

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).

@mattclay
Copy link
Member

@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?

@mattclay
Copy link
Member

@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.

@felixfontein
Copy link
Contributor Author

@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.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 31, 2023
@mattclay
Copy link
Member

@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.

@felixfontein felixfontein marked this pull request as ready for review March 31, 2023 21:12
@felixfontein
Copy link
Contributor Author

@mattclay done

@mattclay mattclay merged commit 2f647e9 into ansible:devel Mar 31, 2023
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. labels Mar 31, 2023
@felixfontein felixfontein deleted the semantic-markup-ansible-test branch March 31, 2023 21:17
@felixfontein
Copy link
Contributor Author

#80383 contains the follow-up PR which replaces the parsing/rendering code with code from antsibull-docs-parser.

@ansible ansible locked and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 feature This issue/PR relates to a feature request. has_issue needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants