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 flag to re-write sidebar.js (and other auto-generated files) #983

Open
rossdanlm opened this issue Oct 3, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@rossdanlm
Copy link

Is your feature request related to a problem?

Similar to #615 (comment), I noticed that changes to the OpenAPI specs aren't reflected in sidebar.ts file:

if (!fs.existsSync(`${outputDir}/sidebar.ts`)) {
try {
fs.writeFileSync(`${outputDir}/sidebar.ts`, view, "utf8");
console.log(
chalk.green(`Successfully created "${outputDir}/sidebar.ts"`)
);
} catch (err) {
console.error(
chalk.red(`Failed to write "${outputDir}/sidebar.ts"`),
chalk.yellow(err)
);
}
}
}

I think it would be nice to add an --overwrite arg in CLI that would allow you to overwrite this!

Describe the solution you'd like

Something similar to docusaurus gen-api-docs <plugin_id> --overwrite

Describe alternatives you've considered

Not blocked, able to just clean/delete the repo but it would be a nice step to include. It wasn't super obvious to me when I first did this and spend some time trying to debug why my updates weren't appearing in my docs.

Perhaps also maybe in output text say "warning: OpenAPI spec differs from data currently saved in <destination_path>.sidebar.ts file. If you would like to update this file, please re-run with the --overwrite flag: docusaurus gen-api-docs <plugin_id> --overwrite"

Additional context

@rossdanlm rossdanlm added the enhancement New feature or request label Oct 3, 2024
rossdanlm added a commit to lastmile-ai/lastmile-docs that referenced this issue Oct 3, 2024
## Summary

We needed to update the production `model.json` file with some extra fields in https://app.graphite.dev/github/pr/lastmile-ai/lmai/888/Add-summary-and-operationId-and-tags-to-model-json-when-generating-OpenAPI-spec-from-protobufs

FYI I had to delete the `docs/api/sidebar.ts` file since the changes don't update for that file (https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/00631740bd7a06d447ed7eb2aa4b7b7259593e71/packages/docusaurus-plugin-openapi-docs/src/index.ts#L181-L194). Something we should automate better and keep in mind or future. The author of this plugin also say we can use the `--clean` flag as well: PaloAltoNetworks/docusaurus-openapi-docs#615 (comment). I submitted a feature request lol: PaloAltoNetworks/docusaurus-openapi-docs#983

## Changelist
- `model.json` files generated from PR metnioned above
- deleted the `docs/api/index.md` since this is automatically taken care of by docusaurus and we don't need it

## Test Plan
Check that prod works and everything is properly grouped by the service name

<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/N4CMfFKE7hFMNsyItsnM/0687a91c-2744-4818-9449-94d7adfa19c1.mp4">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/N4CMfFKE7hFMNsyItsnM/0687a91c-2744-4818-9449-94d7adfa19c1.mp4">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/N4CMfFKE7hFMNsyItsnM/0687a91c-2744-4818-9449-94d7adfa19c1.mp4">Screen Recording 2024-10-03 at 02.02.44.mp4</video>

---
@sserrata
Copy link
Member

sserrata commented Oct 4, 2024

Hi @rossdanlm, I think this is something we can implement/support. Any chance you'd be willing/interested in working on it?

Also, FWIW, we chose not to check-in our generated MDX/sidebar files for our project, i.e. we use .gitignore to exclude them. This helps ensure we always generated the latest OpenAPI docs, accounting for added/removed/changed operations. Although overwriting seems like a good approach, it probably won't handle cases where operations are removed, since those would require manual cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants