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

docs: use stardoc proto output to generate markdown docs #1629

Merged
merged 11 commits into from Dec 20, 2023

Conversation

rickeylev
Copy link
Contributor

The template language Stardoc uses (Velocity) is niche and fairly
esoteric, and requires a lot of experimenting to understand how to
make it produce the desired output. In particular, it largely assumes
whitespace doesn't matter, which makes it a poor fit for generating
Markdown, where whitespace often does matter.

Instead, a small Python program is used to consume the binary proto
output of Stardoc, which converts it to Markdown. This also makes it
easier to customize the overall output and re-use code for the different
types of objects rendered.

The visible changes to the docs are:

  • Module extensions are now documented
  • Repository rules follow the style of the other generated docs
  • Fixed the rendering of pip_repository docs -- it had an h2
    section which broke the section grouping of the API objects.
  • Puts some padding between the border and content for text in
    params/attrs/fields listings.

Other notable changes:

  • Make RTD builds use bzlmod. This is necessary so that the pip
    extension can be documented. It loads
    @pythons_hub//:interpreters.bzl, but that repo is only created
    when bzlmod is enabled)

@rickeylev rickeylev marked this pull request as ready for review December 18, 2023 19:45
@rickeylev
Copy link
Contributor Author

Ah doh, need to fix a few test failures before review.

The template language Stardoc uses (Velocity) is niche and fairly
esoteric, and requires a lot of experimenting to understand how to
make it produce the desired output. In particular, it largely assumes
whitespace doesn't matter, which makes it a poor fit for generating
Markdown, where whitespace often does matter.

Instead, a small Python program is used to consume the binary proto
output of Stardoc, which converts it to Markdown. This also makes it
easier to customize the overall output and re-use code for the different
types of objects rendered.

The visible changes to the docs are:
  * Module extensions are now documented
  * Repository rules follow the style of the other generated docs
  * Fixed the rendering of pip_repository docs -- it had an h2
    section which broke the section grouping of the API objects.
  * Puts some padding between the border and content for text in
    params/attrs/fields listings.

Other notable changes:
  * Make RTD builds use bzlmod. This is necessary so that the pip
    extension can be documented. It loads
    `@pythons_hub//:interpreters.bzl`, but that repo is only created
    when bzlmod is enabled)
for some reason, it crashes the stardoc interpreter under bazel 6.
@rickeylev
Copy link
Contributor Author

Ok, tests fixed. Just windows flakes left.

docs/sphinx/BUILD.bazel Show resolved Hide resolved
sphinxdocs/private/proto_to_markdown.py Outdated Show resolved Hide resolved
sphinxdocs/private/proto_to_markdown.py Outdated Show resolved Hide resolved
sphinxdocs/private/proto_to_markdown.py Show resolved Hide resolved
sphinxdocs/private/proto_to_markdown.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

LGTM and merging since the questions are very minor.

@@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@docs_deps//:requirements.bzl", "requirement")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@dev_pip//:requirements.bzl", "requirement")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: technically I think we don't need this macro anymore as the same alias labels can be accessed from WORKSPACE and MODULE.bazel setups.

docs/sphinx/_stardoc_footer.md Show resolved Hide resolved
@aignas aignas added this pull request to the merge queue Dec 20, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 20, 2023
@rickeylev rickeylev added this pull request to the merge queue Dec 20, 2023
Merged via the queue into bazelbuild:main with commit 509b02f Dec 20, 2023
3 checks passed
@rickeylev rickeylev deleted the docs.proto.template branch December 20, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants