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

Doc module render fixes #5562

Merged
merged 6 commits into from
Aug 19, 2024
Merged

Conversation

blackboxsw
Copy link
Collaborator

@blackboxsw blackboxsw commented Jul 26, 2024

Fix incorrectly redacted module property documentation for Users and Groups and Rsyslog for nested JSON schemas which contain alternative oneOf schemas.

The bulk of this work was made easier by adding the ability to debug the rendered RST files to see bogus white-space indentation that sphinx was able to smooth out.

When building docs, a developer/reviewer can now look at individually rendered RST content for any config module with the following environment variable:

CLOUD_INIT_DEBUG_MODULE_DOC_FILE=/tmp/doc.cc_rsyslog CLOUD_INIT_DEBUG_MODULE_DOC=cc_rsyslog tox -e doc

To render all module docs CLOUD_INIT_DEBUG_MODULE_DOC=all can be provided instead

Proposed Commit Message

--- See individual commits

Additional Context

Test Steps

tox -e doc
xdg-open doc/rtd_html/reference/modules.html   # Navigate to rsyslog and "users and groups" schema tabs to compare local render versus public docs for the same schema tabs

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@github-actions github-actions bot added the documentation This Pull Request changes documentation label Jul 26, 2024
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Jul 26, 2024
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Jul 26, 2024
…ical#5562)

Without this fix, rendered module documentation was not rendering the
following text for some objects:

Each object in **<key_name>** list supports the following keys:

See Rsyslog Config schema tab.
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Jul 26, 2024
…cal#5562)

Document any keys of objects in a list which allows for objects as one
of the alternative types allowed as a list item.

Also, when documenting properties, ensure we skip documentation of
either 'properties' or 'patternProperties' if those properties are
declared in the hidden key.

Fixes canonicalGH-5514
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Jul 26, 2024
…5562)

When running tox -e doc the following environment variables are
supported:
  CLOUD_INIT_DEBUG_MODULE_DOC=cc_<module_id>
  CLOUD_INIT_DEBUG_MODULE_DOC_FILE=<file_path>

The env var CLOUD_INIT_DEBUG_MODULE_DOC can be set to either
a specific module id, such as cc_rsyslog, or 'all'.

When set the rendered module documentation RST format is printed
inline to stdout to allow for quick analysis of rendered content.

Optionally, if CLOUD_INIT_DEBUG_MODULE_DOC_FILE is set to a writable
file path, the output of the rendered content is written to that file
instead.

This supports development of docs and quick comparison of docs
generated before and after a changeset.
@holmanb holmanb self-assigned this Jul 29, 2024
Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

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

Overall this looks like a big visual improvement alongside the missing keys being back. The only issue I can see is that in deeper levels, there is a missing newline (Ansible is conveniently the first example!) so that it looks like keys are missing (they're stuck on the previous line:
image

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

see @s-makin's comment

@blackboxsw
Copy link
Collaborator Author

CLOUD_INIT_DEBUG_MODULE_DOC_FILE=/tmp/doc.cc_rsyslog CLOUD_INIT_DEBUG_MODULE_DOC=cc_rsyslog tox -e doc

Thanks @s-makin. I hadn't realized I got a bit greedy with my jinja template newline chomping at the end of each rendered content in the module_property.tmpl. The following diff fixes this:

--- a/doc/rtd/templates/module_property.tmpl
+++ b/doc/rtd/templates/module_property.tmpl
@@ -1,7 +1,7 @@
 {% macro print_prop(name, types, description, prefix) -%}
 {% set descr_suffix = description.splitlines()[0]|d('') -%}
 {% set descr_lines = description.splitlines()[1:]|d([]) -%}
-{{prefix}}* **{{name}}:** ({{types}}){{ descr_suffix -}}
+{{prefix}}* **{{name}}:** ({{types}}){{ descr_suffix }}
 {% for line in descr_lines -%}
 {{prefix ~ '  '}}{{ line }}
 {% endfor -%}

blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…ical#5562)

Without this fix, rendered module documentation was not rendering the
following text for some objects:

Each object in **<key_name>** list supports the following keys:

See Rsyslog Config schema tab.
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…cal#5562)

Document any keys of objects in a list which allows for objects as one
of the alternative types allowed as a list item.

Also, when documenting properties, ensure we skip documentation of
either 'properties' or 'patternProperties' if those properties are
declared in the hidden key.

Fixes canonicalGH-5514
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…5562)

When running tox -e doc the following environment variables are
supported:
  CLOUD_INIT_DEBUG_MODULE_DOC=cc_<module_id>
  CLOUD_INIT_DEBUG_MODULE_DOC_FILE=<file_path>

The env var CLOUD_INIT_DEBUG_MODULE_DOC can be set to either
a specific module id, such as cc_rsyslog, or 'all'.

When set the rendered module documentation RST format is printed
inline to stdout to allow for quick analysis of rendered content.

Optionally, if CLOUD_INIT_DEBUG_MODULE_DOC_FILE is set to a writable
file path, the output of the rendered content is written to that file
instead.

This supports development of docs and quick comparison of docs
generated before and after a changeset.
@blackboxsw blackboxsw requested a review from holmanb August 2, 2024 21:09
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…ical#5562)

Without this fix, rendered module documentation was not rendering the
following text for some objects:

Each object in **<key_name>** list supports the following keys:

See Rsyslog Config schema tab.
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…cal#5562)

Document any keys of objects in a list which allows for objects as one
of the alternative types allowed as a list item.

Also, when documenting properties, ensure we skip documentation of
either 'properties' or 'patternProperties' if those properties are
declared in the hidden key.

Fixes canonicalGH-5514
blackboxsw added a commit to blackboxsw/cloud-init that referenced this pull request Aug 2, 2024
…5562)

When running tox -e doc the following environment variables are
supported:
  CLOUD_INIT_DEBUG_MODULE_DOC=cc_<module_id>
  CLOUD_INIT_DEBUG_MODULE_DOC_FILE=<file_path>

The env var CLOUD_INIT_DEBUG_MODULE_DOC can be set to either
a specific module id, such as cc_rsyslog, or 'all'.

When set the rendered module documentation RST format is printed
inline to stdout to allow for quick analysis of rendered content.

Optionally, if CLOUD_INIT_DEBUG_MODULE_DOC_FILE is set to a writable
file path, the output of the rendered content is written to that file
instead.

This supports development of docs and quick comparison of docs
generated before and after a changeset.
@blackboxsw
Copy link
Collaborator Author

Pushed two extra commits here that don't have to be in this review. But the intent is to avoid using italics for our entire deprecated key messaging as the deprecated descriptions typically use RST to emphasize the preferred new key resulting in a poorly rendered message like the attached image below

Screenshot from 2024-08-02 15-27-09

@blackboxsw
Copy link
Collaborator Author

Pushed two extra commits here that don't have to be in this review. But the intent is to avoid using italics for our entire deprecated key messaging as the deprecated descriptions typically use RST to emphasize the preferred new key resulting in a poorly rendered message like the attached image below

Screenshot from 2024-08-02 15-27-09

With the most recent 2 commits added, the rendered formatting with an italicized Deprecated prefix and bold looks like the following:
Screenshot from 2024-08-02 16-13-36

Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Haven't spotted any more wrongly-formatted bullet lists. The only inconsistencies now come from the individual files that the docs are generated from, and it's beyond the scope of this PR to fix those so happy to see this merged :)

…ical#5562)

Without this fix, rendered module documentation was not rendering the
following text for some objects:

Each object in **<key_name>** list supports the following keys:

See Rsyslog Config schema tab.
…cal#5562)

Document any keys of objects in a list which allows for objects as one
of the alternative types allowed as a list item.

Also, when documenting properties, ensure we skip documentation of
either 'properties' or 'patternProperties' if those properties are
declared in the hidden key.

Fixes canonicalGH-5514
…5562)

When running tox -e doc the following environment variables are
supported:
  CLOUD_INIT_DEBUG_MODULE_DOC=cc_<module_id>
  CLOUD_INIT_DEBUG_MODULE_DOC_FILE=<file_path>

The env var CLOUD_INIT_DEBUG_MODULE_DOC can be set to either
a specific module id, such as cc_rsyslog, or 'all'.

When set the rendered module documentation RST format is printed
inline to stdout to allow for quick analysis of rendered content.

Optionally, if CLOUD_INIT_DEBUG_MODULE_DOC_FILE is set to a writable
file path, the output of the rendered content is written to that file
instead.

This supports development of docs and quick comparison of docs
generated before and after a changeset.
@blackboxsw
Copy link
Collaborator Author

@holmanb I rebased against main to resolve merge conflicts. If you get a chance can we peek at this please.

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @blackboxsw!

@blackboxsw blackboxsw merged commit a2193da into canonical:main Aug 19, 2024
19 of 21 checks passed
blackboxsw added a commit that referenced this pull request Aug 19, 2024
blackboxsw added a commit that referenced this pull request Aug 19, 2024
Without this fix, rendered module documentation was not rendering the
following text for some objects:

Each object in **<key_name>** list supports the following keys:

See Rsyslog Config schema tab.
blackboxsw added a commit that referenced this pull request Aug 19, 2024
Document any keys of objects in a list which allows for objects as one
of the alternative types allowed as a list item.

Also, when documenting properties, ensure we skip documentation of
either 'properties' or 'patternProperties' if those properties are
declared in the hidden key.

Fixes GH-5514
blackboxsw added a commit that referenced this pull request Aug 19, 2024
When running tox -e doc the following environment variables are
supported:
  CLOUD_INIT_DEBUG_MODULE_DOC=cc_<module_id>
  CLOUD_INIT_DEBUG_MODULE_DOC_FILE=<file_path>

The env var CLOUD_INIT_DEBUG_MODULE_DOC can be set to either
a specific module id, such as cc_rsyslog, or 'all'.

When set the rendered module documentation RST format is printed
inline to stdout to allow for quick analysis of rendered content.

Optionally, if CLOUD_INIT_DEBUG_MODULE_DOC_FILE is set to a writable
file path, the output of the rendered content is written to that file
instead.

This supports development of docs and quick comparison of docs
generated before and after a changeset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This Pull Request changes documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants