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

Include "provider" value for BUILD file symbols in help-all output #20976

Open
huonw opened this issue May 30, 2024 · 1 comment
Open

Include "provider" value for BUILD file symbols in help-all output #20976

huonw opened this issue May 30, 2024 · 1 comment

Comments

@huonw
Copy link
Contributor

huonw commented May 30, 2024

Is your feature request related to a problem? Please describe.

For doc generation purposes (pantsbuild/pantsbuild.org#216), it would be nice to indicate what backend a "BUILD file symbol" comes from, but that information isn't available.

We have various BUILD file symbols like __defaults__, PANTS_VERSION, node_build_script, stevedore_namespace which are functions or constants that aren't targets. Currently, pants help-all shows these in name_to_build_file_info, but it has pretty minimal content:

  "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'"
    },
...
    "adhoc_tool": {
      "documentation": null,
      "is_target": true,
      "name": "adhoc_tool",
      "signature": "(**kwargs: 'Any') -> 'TargetAdaptor'"
    },
...

(Note that targets also appear, but are easy to filter out.)

Describe the solution you'd like

A provider value available for BUILD file symbols somehow, either in name_to_build_file_info or by putting them in their own section.

For example, this is what goals shows:

  "name_to_goal_info": {
    "check": {
      "consumed_scopes": [
        "",
        "check",
        "environments-preview",
        "filter"
      ],
      "description": "Run type checking or the lightest variant of compilation available for a language.",
      "is_implemented": true,
      "name": "check",
      "provider": "pants.core"
    },

Describe alternatives you've considered
N/A

Additional context

@huonw
Copy link
Contributor Author

huonw commented May 30, 2024

I guess this could appear in the pants help env output too.

huonw added a commit to pantsbuild/pantsbuild.org that referenced this issue May 30, 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:

```json
  "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](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/e1e1a27c-9cc2-47e1-ac07-644a1c019ae8)


Some of these have reasonable docs:


![image](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/b453a0ad-055b-4ef9-b7b9-9528782f1d02)


![image](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/3f11ca66-85a2-49cc-87f4-fe36ed75a960)


Others do not have good docs:


![image](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/83df063c-2a59-434c-8d8e-878d6b57ac3e)


![image](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/121f3c2e-10a3-491c-b836-f9cad0256d31)



![image](https://github.com/pantsbuild/pantsbuild.org/assets/1203825/76a07178-de41-4022-b29c-56a6f04f191e)


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

- pantsbuild/pants#20976
- pantsbuild/pants#20977
- pantsbuild/pants#20978
- pantsbuild/pants#20979
- pantsbuild/pants#20980


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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant