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

chore: add docgen script #7387

Merged
merged 3 commits into from
Aug 20, 2024
Merged

chore: add docgen script #7387

merged 3 commits into from
Aug 20, 2024

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Aug 19, 2024

Description

Adds a script to the monorepo that allows generating documents based on a template. Useful for testing.

Usage: tsx --env-file=.env.local ./scripts/generate-documents/cli.ts --template <template> [arguments]

     Arguments:
      --template, -t <template>: Template to use (required). Possible values: validation, book, species

      --dataset: Dataset to generate documents in (defaults to 'test')
      --amount, -n <int>: Number of documents to generate
      --draft: Generate draft documents
      --published: Generate published documents
      --size <bytes>: Size (in bytes) of the generated document (will be approximated)
      --concurrency, -c <int>: Number of concurrent requests
      --help, -h: Show this help message

  Add more templates by adding them to the "./scripts/generate-documents/templates" directory.

Can also be run via pnpm run generate:docs, e.g. pnpm run generate:docs --template book

Requires an environment variable in .env.local that points at a valid write token for the test project:

# .env.local
TEST_STUDIO_WRITE_TOKEN=

What to review

Does it make sense?

Testing

n/a internal dev tooling

Notes for release

n/a

@bjoerge bjoerge requested a review from a team as a code owner August 19, 2024 18:02
@bjoerge bjoerge requested review from cngonzalez and removed request for a team August 19, 2024 18:02
Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 9:16am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 9:16am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 9:16am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 9:16am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 9:16am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 9:16am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Aug 19, 2024

Component Testing Report Updated Aug 20, 2024 9:25 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 47s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 51s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 18s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 28s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ❌ Failed (Inspect) 1m 27s 20 0 1
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 1m 52s 30 0 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 20s 3 0 0

{
_type: 'span',
marks: [],
text: lorem(options.size / 2),
Copy link
Contributor

Choose a reason for hiding this comment

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

going to be honest the names of these functions felt a bit cryptic initially 😄
I think we could benefit from having a small comment / a slight renaming over on lorem-bytes.ts ?

Copy link
Member Author

Choose a reason for hiding this comment

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

what was cryptic about them? what would be a better name?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that in terms of naming it could be something related more to getSampleText or something along those lines (though I'm not married to the name, the name lorem does invoke sample / placeholder text)

However, my first gut feeling was: why do I have to pass the options.size into this, and what does it have to do with the sampling. Just to confirm that I understood it, this is more about making sure that the content in this PTE is not all the same text so that there is some variation between the docs generated, right?

Copy link
Member Author

@bjoerge bjoerge Aug 20, 2024

Choose a reason for hiding this comment

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

Renamed lorem to loremString and added some tsdocs here – hopefully that made things a bit clearer :)

Copy link
Member Author

@bjoerge bjoerge Aug 20, 2024

Choose a reason for hiding this comment

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

getSampleText would be ok, but loremText feels more specific (it is generating lorem-ipsum text after all).

Just to confirm that I understood it, this is more about making sure that the content in this PTE is not all the same text so that there is some variation between the docs generated, right?

Yep! Sometimes you might want to generate large documents, so this provides the ability to specify the desired byte size of the documents you're generating.

RitaDias
RitaDias previously approved these changes Aug 20, 2024
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

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

Just a small comment, otherwise this is really nice :)
I was thinking while reviewing if this isn't something that would be useful to have directly on next though. Sure it wouldn't have the bundle things but it is a pretty useful thing overall.

@bjoerge
Copy link
Member Author

bjoerge commented Aug 20, 2024

I was thinking while reviewing if this isn't something that would be useful to have directly on next though. Sure it wouldn't have the bundle things but it is a pretty useful thing overall.

Excellent point - will make it towards next.

@bjoerge
Copy link
Member Author

bjoerge commented Aug 20, 2024

Changed the base to next and pushed two small commits:

  • Renaming the lorem functions and adding tsdoc (hope that helps!): c0b4a80
  • Adding --bundle to help text: 7802e15

@bjoerge bjoerge requested a review from RitaDias August 20, 2024 09:10
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

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

@bjoerge bjoerge added this pull request to the merge queue Aug 20, 2024
Merged via the queue into next with commit e3a02c4 Aug 20, 2024
40 of 41 checks passed
@bjoerge bjoerge deleted the add-doc-gen-script branch August 20, 2024 09:18
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.

2 participants