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

Regenerate reference docs from in-repo sources #50

Merged
merged 6 commits into from
Jan 4, 2024

Conversation

huonw
Copy link
Contributor

@huonw huonw commented Jan 3, 2024

This runs for d in docs versioned_docs/*; do npm run generate-reference $d; done, npm run format-all to regenerate all docs off the help-all.json files that are now checked in (#43).

Fixes #37, hopefully.

Copy link
Contributor Author

@huonw huonw left a comment

Choose a reason for hiding this comment

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

It looks like there's a few places where the generation script potentially has the wrong behaviour.

@@ -559,7 +563,7 @@ Directory to use for named global caches for tools and processes with trusted, c
<Option
cli_repr={`--local-execution-root-dir=<str>`}
env_repr='PANTS_LOCAL_EXECUTION_ROOT_DIR'
default_repr={`/tmp`}
default_repr={`<buildroot>`}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this change correct?

Copy link
Member

Choose a reason for hiding this comment

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

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, this looks like a bug in the generations script, at some point I think pants_workdir changed defaults.

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 think we can let this one go, it looks like a "problem" in existing docs before 2.13:

And indeed, the docs match, e.g. 2.20:

env_repr='PANTS_LOCAL_EXECUTION_ROOT_DIR'
default_repr={`<tmp_dir>`}

Copy link
Member

Choose a reason for hiding this comment

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

I split this into a dedicated issue: #60

versioned_docs/version-2.0.x/reference/goals/awslambda.mdx Outdated Show resolved Hide resolved
versioned_docs/version-2.0.x/reference/goals/awslambda.mdx Outdated Show resolved Hide resolved
versioned_docs/version-2.0.x/reference/targets/archive.mdx Outdated Show resolved Hide resolved
versioned_docs/version-2.0.x/reference/targets/archive.mdx Outdated Show resolved Hide resolved
Comment on lines 19 to 28
To remove a prefix:

```
# Results in `data.json`.
relocated_files(
file_targets=["src/resources/project1:target"],
src="src/resources/project1",
dest="",
)

```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the spacing has gone a bit weird here.

Copy link
Member

Choose a reason for hiding this comment

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

Possibly

Copy link
Member

Choose a reason for hiding this comment

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

Fixed in #53

Copy link
Member

Choose a reason for hiding this comment

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

Although, how did you re-generate the docs here? That red line should've been fixed by prettier. Did you run prettier after running the generation command?

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 didn't; I didn't realise I had to :)

Copy link
Member

Choose a reason for hiding this comment

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

If there was a way to have it run in the script definition (e.g. run the generation and format) id +1 that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in #65 (review)

@huonw
Copy link
Contributor Author

huonw commented Jan 4, 2024

(Waiting for #54 before I check over this again.)

@huonw
Copy link
Contributor Author

huonw commented Jan 4, 2024

I've done some very quicks spot checks of the diff and of the rendering, and it seems fine.

@huonw huonw requested a review from thejcannon January 4, 2024 04:44
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.

Let's goooo!

@huonw huonw merged commit 38e1bda into pantsbuild:main Jan 4, 2024
1 check passed
@huonw huonw deleted the huonw/37-regenerate branch January 4, 2024 21:28
huonw added a commit that referenced this pull request Jan 5, 2024
This does a bunch of leg work to have the reference files be reformatted
(with prettier) as they are written. This makes the generation notably
slower (slightly less than 1s -> slightly less than 4s on my machine),
but saves from having to remember to run the formatting separately...
which takes just as long as the extra time anyway.

This requires a few steps, broken across commits in a useful way (with
some not-strictly-necessary changes), because prettier only has an async
API. This seems to require running as an `.mjs` ("module") rather than
`.js` to be able to use `await` at the top level.

After getting to using async + prettier, this then makes a few changes
that this allows:

- a neater way to write the JSON files
- writing all files concurrently with `Promise.all` (writing the targets
and subsystems concurrently takes the time from ~4.4s -> ~3.8s, doing
the others concurrently makes no difference, but makes the code look
uniform).

See also:
#50 (comment)
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.

Auto-synced reference docs don't match checked-in code, thus sync PRs have spurious changes
2 participants