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

feat: sync docs (by copying them) #69

Merged
merged 15 commits into from
Sep 9, 2024
Merged

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Sep 2, 2024

Alternative to #55

Closes #20

This implements a different approach to syncing the docs. Rather than creating a toolchain that requires git sync or similar on build and keeps things transient, this approach implements a script that is invoked separately (and can be part of a github action for example) that mostly copies the documentation from the target repositories over into the omnisite, while also invoking scripts for creating the generated reference docs. Detailed steps:

  1. pnpm sync-docs triggers sync script (can be invoked locally, from a github action, whatever)
  2. script git clones the needed repositories (Svelte, SvelteKit etc) into a gitignored folder
  3. script copies over documentation from cloned repositories
  4. script runs the docs reference generation script on the cloned repositories' types and replaces placeholders from copied over documentation which reference sections from said generated docs
  5. commit result into the content folder

Running the build (i.e. building the site using the committed content and the app code) can then be done separately.

Because the result is saved to disk, and syncing and building are split, we get a few advantages:

  • build is massively simpler and faster: no dependencies on flaky git or other remote sources, no waiting on assembling and generating all the docs, as everything is already there
  • syncing docs can be done in a separate Github action, and the resulting PR will give us a nice sanity check about what exactly changed
  • getting started is easier, no need to sync first, just checkout the repo and go. This is especially helpful if you're working on the site itself, not the content
  • translations will be easier: just don't invoke the sync script, instead modify the directories by hand. Keeping up to date with the source will also be easier because you can git-diff changes to docs
  • more robust to future changes: If we change how the generated docs approach works, or other things related to how docs are structured in the other repositories, we don't need to backport that to old versions which we don't maintain anymore. Instead, they just become a frozen snapshot, and potentially we can even update some by hand if needed. I'm not saying we need/want to do this, just that we have this as an option available to us - something we wouldn't have if the docs were transient

At the same time, this lays the foundation for versioning; kit and svelte docs are both inside a v02/v05 directory (leading 0 to not mess up ordering once we're in double digits). Versioning is implemented in follow-up PR in #70.

This implements a different approach to syncing the docs. Rather than creating a toolchain that requires git sync or similar on build and keeps things transient, this approach implements a script that is invoked separately (and can be part of a github action for example) that mostly copies the documentation from the target repositories over into the omnisite, while also invoking scripts for creating the generated reference docs. The result is saved to disk, which has a few advantages:
- build is massively simpler: no dependencies on flaky git or other remote sources, as everything is already there
- getting started is easier, no need to sync first, just checkout the repo and go. This is especially helpful if you're working on the site itself, not the content
- translations will be easier: just don't invoke the sync script, instead modify the directories by hand. Keeping up to date with the source will also be easier because you can git-diff changes to docs

At the same time, this lays the foundation for versioning; kit and svelte docs are both inside a v02/v05 directory (leading 0 to not muss up ordering once we're in double digits)
Copy link

vercel bot commented Sep 2, 2024

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

Name Status Preview Comments Updated (UTC)
omnisite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 4:27pm

@benmccann
Copy link
Member

I see sync-docs.ts is still doing a git clone. When would that be run and for what purpose?

@dummdidumm
Copy link
Member Author

It's doing git clone when we want it to (you can choose by modifying the script, default is off). This allows us to

  • run this from a github action (which doesn't have repos as siblings on some file system)
  • run this for branches (allows us to do versioning through that, also see feat: docs versioning #70)

Copy link
Collaborator

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

I'm onboard with this approach and having thought about things – is the most scalable approach for us right now.

@dummdidumm dummdidumm merged commit 883bc6f into main Sep 9, 2024
3 checks passed
@dummdidumm dummdidumm deleted the sync-docs-copy-approach branch September 9, 2024 18:10
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.

Sync generated docs into this repo
3 participants