Skip to content

Conversation

@blittle
Copy link
Contributor

@blittle blittle commented Oct 6, 2023

WHY are these changes introduced?

At the moment it's really difficult to build reference docs, because the docs generation system builds a large json file, which then needs to be copied to a spin instance to preview the final output.

WHAT is this pull request doing?

This creates a tool that allows you to preview the docs in a local remix app. It has HMR and stays up to date as you continually build the docs. It doesn't have 100% of the features of the final docs experience, but it should help us create docs more quickly without going directly to spin.

HOW to test your changes?

Run npm run preview-docs from both packages/hydrogen and packages/hydrogen-react

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run npm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.


console.log('Watching: ' + docsMetaFile);

async function run() {
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 don't love this code, but it works. Initially I passed an env variable to the remix app with the path to the metafile. Then the remix app could just fs.readFile the metafile within a loader. The issue is it didn't pickup changes. It's kinda heavy to copy a whole file into the remix app, but it seemed simplest to just do that have have all of Remix's dev-server file watchers take care of everything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hope you love it more now 😂 8433ccc

@frandiox
Copy link
Contributor

Great tool! Made some changes to fix hot refresh.

Maybe the tool should live in docs/preview instead of packages/docs-preview?

Comment on lines 22 to 23
delete require.cache[process.env.DOCS_META_FILE!];
const data = require(process.env.DOCS_META_FILE!);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! This is what I didn't know how to do!

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