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

refactor: simplify version mapping logic #1328

Merged
merged 4 commits into from Sep 30, 2022

Conversation

pepopowitz
Copy link
Collaborator

Part of #1217

What is the purpose of the change

Refactors the version mapping logic (i.e. docs v8.0 <=> optimize v3.8.0) to simplify its external API.

At time of cutting new versions, this logic would have required detailed changes that were prone to mistakes. With this refactor, updating this file involves nothing more than specifying the new docs & optimize versions.

This PR also updates the tests associated with this logic based on the correct version mappings (I forgot to update them when I extracted v3.8.0 of Optimize!)

Are there related marketing activities

No

When should this change go live?

Should have no effect to production, but merging in the next couple days is probably best in terms of getting things ship-shape for the upcoming version release.

PR Checklist

  • My changes apply to an already released version, and I have added them to the relevant /versioned_docs directory, or they are not for an already released version.
  • My changes apply to future versions, and I have added them to the main /docs directory, or they are not for future versions.
  • My changes require an Engineering review, and I've assigned an engineering manager or tech lead as a reviewer, or my changes do not require an Engineering review.
  • My changes require a technical writer review, and I've assigned @christinaausley as a reviewer, or my changes do not require a technical writer review.

@pepopowitz pepopowitz added component:docs Documentation improvements, including new or updated content dx Documentation infrastructure typically handled by the Camunda DX team epic:optimize-versions labels Sep 29, 2022
@pepopowitz pepopowitz self-assigned this Sep 29, 2022
src/mdx/expandVersionedUrl.js Outdated Show resolved Hide resolved
Comment on lines 10 to 17
const versionMappings = [
// When cutting a new version, add a new mapping here!
{
token: "$optimize$",
rules: [
// TODO: introduce these mappings, as versions are added for optimize.
{ match: "/docs/", expandTo: "/optimize/next" },
{ match: "/versioned_docs/version-8.0/", expandTo: "/optimize" },
// { match: "/versioned_docs/version-1.3/", expandTo: "/optimize/3.7.0" },
],
docsVersion: "8.0",
optimizeVersion: "3.8.0",
},
{ docsVersion: "1.3", optimizeVersion: "3.7.0" },
];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the payoff of this PR. On the left side we would have had to align the source directories with URLs when adding a new version; on the right, all we have to do is add a new object that aligns the two versions.

Copy link
Member

Choose a reason for hiding this comment

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

🤩 so CLEAN

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I spent some time playing with the idea of removing this mapping entirely -- instead looking at the version files defined for docusaurus, and aligning the two lists of version numbers to come up with this mapping.

I decided to pause on it because while I love the idea of not maintaining this additional list of versions, I think I can simplify the version release process a good amount even with this second list of versions. I might return to the idea in the future though.

Copy link
Member

Choose a reason for hiding this comment

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

A great future topic for sure. If you want, you can already create an issue we can revisit later.

const docsToken = {
token: "$docs$",
rules: [
{ match: "/optimize/", expandTo: "/docs/next" },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could add comments here if you think it'd be useful.

This first rule is for the "next" version, which will always have the same mapping....

Copy link
Member

Choose a reason for hiding this comment

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

This seems clear enough not to need a comment.

rules: [
{ match: "/optimize/", expandTo: "/docs/next" },
{
match: `/optimize_versioned_docs/version-${currentVersions.optimizeVersion}`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

...This second rule maps the current version in the source to the non-versioned URL....

match: `/optimize_versioned_docs/version-${currentVersions.optimizeVersion}`,
expandTo: "/docs",
},
...remainingVersions.map((version) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And for each of the remaining versions, both the source and target URLs have the version in them.

},
{ docsVersion: "1.3", optimizeVersion: "3.7.0" },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't moved any docs for these versions yet, but having this mapping here shouldn't hurt anything (because no docs are using the $docs$/$optimize$ shortcuts in v1.3 yet.)

@@ -21,6 +21,7 @@ describe("expandVersionedUrl", () => {
"/Users/monkeypants/camunda-platform-docs/optimize/what-is-optimize.md",
"/docs/next/some/thing",
],

[
"/Users/monkeypants/camunda-platform-docs/optimize_versioned_docs/version-3.8.0/what-is-optimize.md",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests will fail when we cut a new version. I think that's fine for now -- we don't actually run them as part of CI anyway, and it's less important to me that the tests are robust and more important that versioning is easier.

akeller
akeller previously approved these changes Sep 29, 2022
Copy link
Member

@akeller akeller left a comment

Choose a reason for hiding this comment

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

This looks SO clean. I can't get over it! Thank you! 🚀


/** @type {Array<VersionMapping>} */
const versionMappings = [
// When cutting a new version, add a new mapping here!
Copy link
Member

Choose a reason for hiding this comment

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

💯

@pepopowitz pepopowitz merged commit 127a323 into main Sep 30, 2022
@pepopowitz pepopowitz deleted the pepopowitz/1217-simplify-version-mappings branch September 30, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:docs Documentation improvements, including new or updated content dx Documentation infrastructure typically handled by the Camunda DX team epic:optimize-versions
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants