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

Add reference docs for BUILD file symbols #216

Merged
merged 7 commits into from
May 30, 2024

Conversation

huonw
Copy link
Contributor

@huonw huonw commented May 28, 2024

This adds a new section to the reference docs: /2.x/reference/build-file-symbols/. This renders all the known non-target BUILD file symbols, as indicated by the name_to_build_file_info key of the help-all output JSON.

This JSON looks like the following, and this generation basically just mashes it up into documentation form:

  "name_to_build_file_info": {
    "PANTS_VERSION": {
      "documentation": null,
      "is_target": false,
      "name": "PANTS_VERSION",
      "signature": null
    },
    "__defaults__": {
      "documentation": "Provide default field values.\n\nLearn more https://www.pantsbuild.org/2.22/docs/using-pants/key-concepts/targets-and-build-files#field-default-values",
      "is_target": false,
      "name": "__defaults__",
      "signature": "(*args: 'SetDefaultsT', ignore_unknown_fields: 'bool' = False, ignore_unknown_targets: 'bool' = False, **kwargs) -> 'None'"
    },
    "__dependencies_rules__": {
      "documentation": "Declare dependencies rules.",
      "is_target": false,
      "name": "__dependencies_rules__",
      "signature": "(*args, **kwargs) -> 'None'"
    },
    "__dependents_rules__": {
      "documentation": "Declare dependents rules.",
      "is_target": false,
      "name": "__dependents_rules__",
      "signature": "(*args, **kwargs) -> 'None'"
    },
    "_generator_sources_helper": {
      "documentation": null,
      "is_target": true,
      "name": "_generator_sources_helper",
      "signature": "(**kwargs: 'Any') -> 'TargetAdaptor'"
    },
    "_lockfile": {
      "documentation": null,
      "is_target": true,
      "name": "_lockfile",
      "signature": "(**kwargs: 'Any') -> 'TargetAdaptor'"
    },
...

This is a new sidebar option:

image

Some of these have reasonable docs:

image

image

Others do not have good docs:

image

image

image

I think we should land this and then separately work to improve the documentation of each BUILD file symbol:

To make this work, there's two other changes required, which are done as separate commits:

  • support for back-tick code blocks, to avoid mangling them
  • explicit sidebar positions, so that BUILD file symbols is placed last, rather than before Global options (thus becoming the default)

This generates back to the first version that include that (2.16) and involves some other changes to the code-genned docs, hence this is targeted automation:sync-docs.

Fixes #212

@huonw huonw added the automation:sync-docs An automatic sync of documentation from the pantsbuild/pants repo label May 28, 2024
@huonw huonw force-pushed the huonw/212-build-file-symbols branch from 75f78bf to 376053f Compare May 28, 2024 07:35
@huonw huonw force-pushed the huonw/212-build-file-symbols branch from 376053f to 532d4fd Compare May 28, 2024 07:40
@huonw huonw marked this pull request as ready for review May 28, 2024 07:40
Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

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

Awesome. 🚀

Copy link
Member

@thejcannon thejcannon left a comment

Choose a reason for hiding this comment

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

Amazing work!

return (
<div className="margin-bottom--lg">
<CodeBlock language="python">
{/* if there's no signature, the BUILD file symbol is just a constant... but we don't currently have any info about what that constant is */}
Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah that's a bummer. FWIW we delayed publishing these docs solely because we threw the baby out with the bathwater on documenting constants.

Thank you for doing this, and for not allowing constants to halt a great improvement 👍👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, do you have a reference to any of that? Just want to make sure I'm across any extra issues that were identified to avoid having to rediscover everything.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is what I'm thinking of: pantsbuild/pants#18117

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah cool, thanks. That seems to have some good thinking, particularly relevant to pantsbuild/pants#20978, but none of it seems like major missing pieces that should block this... so I'll get it in.

@huonw huonw merged commit 0420ce9 into pantsbuild:main May 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation:sync-docs An automatic sync of documentation from the pantsbuild/pants repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reference API page is missing pants help symbols content like env and build_file_dir
3 participants