Skip to content

Conversation

williamdalessandro
Copy link

@williamdalessandro williamdalessandro commented Sep 18, 2025

Links

Preview Link showing the response of the test page post exclusion
Asana task

What

This is an implementation of version based directives specifically for Vault- differs from the TFC and TFEnterprise exclusions because those were simplified. Does accurate parsing of the version numbers along with relevant error handling/checks. Created new test suite for the new vault exclusions and added in new test to terraform exclusions

Why

Requested in the above asana ticket

How

Extends upon the existing script and copies the same format however it has unique checks since the exclusion operation is more involved. Made the code look identical so it can be easier to abstract in the future so that any product can have access to inclusions/exclusions, right now it just gets the job done.

Pics

The exclusion file
Screenshot 2025-09-18 at 4 53 11 AM

The result when ran
Screenshot 2025-09-18 at 4 28 41 AM

Testing

Can run

npx vitest scripts/prebuild/mdx-transforms/exclude-vault-content/index.test.mjs

and

npx vitest scripts/prebuild/mdx-transforms/exclude-terraform-content/index.test.mjs

in terminal to see the tests run for these. Added in a testing file

/content/vault/v1.20.x/content/docs/concepts/client-count/test-vault-exclusion.mdx

to see inclusions/exclusions at work. Will remove that file from the PR but want it around for testing reference.

Can spin up locally and see the page at

http://localhost:3000/vault/docs/concepts/client-count/test-vault-exclusion

or

http://localhost:3000/vault/docs/v1.20.x/concepts/client-count/test-vault-exclusion

Other info

Had to recompile the binaries since these are changes that take place in the scripts folder

Things left to do:

  • The following files need to be updated to account for vault exclusions

  • build-mdx-transforms-file.mjs - Added in and tests work

  • build-mdx-transforms-file.test.mjs (No change necessary here)

  • remove this testing file once the PR is deemed as good to go

  • Create a new ticket proposing a new structure change to make this more extensible with a plugin based OOP architecture

@williamdalessandro williamdalessandro requested review from a team as code owners September 18, 2025 08:58
@github-actions github-actions bot added the Vault Content update for Vault product docs label Sep 18, 2025
Copy link

github-actions bot commented Sep 18, 2025

Vercel Previews Deployed

Name Status Preview Updated (UTC)
Dev Portal ✅ Ready (Inspect) Visit Preview Thu Oct 2 05:55:04 UTC 2025
Unified Docs API ✅ Ready (Inspect) Visit Preview Thu Oct 2 05:46:23 UTC 2025

Copy link

github-actions bot commented Sep 18, 2025

Broken Link Checker

No broken links found! 🎉


This content should always appear.

<!-- BEGIN: VLT:>=v1.21.x -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure not to include this file when we ship this PR.

Copy link
Contributor

@RubenSandwich RubenSandwich left a comment

Choose a reason for hiding this comment

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

Let's created a shared.mjs file to keep some of the duplication down and keep the remark transforms contained.

https://github.com/hashicorp/web-unified-docs/pull/962/files#r2361077992

@schavis
Copy link
Contributor

schavis commented Sep 23, 2025

Does the inclusion work for partials?

@williamdalessandro
Copy link
Author

williamdalessandro commented Sep 23, 2025

Does the inclusion work for partials?

@schavis Hey so from looking at the code, content is excluded before partials are processed, so this would mean that it currently doesn't work for partials- however I'll work to change that

await expect(async () => {
return await customRunTransform(markdown, vaultVersion, filePath)
}).rejects.toThrow(
'Directive block CONSUL:>=v1.15.x could not be parsed between lines 2 and 4',
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it might be better to do a regex match against the error thrown rather than an exact string match. Just to make the test more robust. That way if the error message changes for casing or punctuation, it won't fail.

const directive = rest.join(':') // Handle edge cases like "TFEnterprise:only name:something"

// Explicit routing
if (product === 'Vault') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah doing it in separate ones is likely the way forward here. 😢

Let's move this to a dictionary function call though to clean up the code. e.g.

const directiveProcessingFuncs = {
  Vault: processVaultBlock,
  TFC: processTFCBlock,
  TFEnterprise: processTFEnterpriseBlock,
}

directiveProcessingFuncs[product](directive, block, tree, options)

Copy link
Author

Choose a reason for hiding this comment

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

this change sounds good

@RubenSandwich
Copy link
Contributor

RubenSandwich commented Sep 29, 2025

Does the inclusion work for partials?

@schavis Hey so from looking at the code, content is excluded before partials are processed, so this would mean that it currently doesn't work for partials- however I'll work to change that

@williamdalessandro it looks like that was done on purpose, by me; https://github.com/hashicorp/web-unified-docs-internal/pull/237/commits/c2c9dd65a7e699a9877c63a5d0e2b230d3a0bb6e. I can't exactly remember why though as it was during a push to get some TFE documentation out the door. I dug through a bunch of slack chat logs and this was the closest I could find that might give a hint here.

Overall what I am saying is that I am okay with changing it, but let's add some tests for the partial then remove content Plugin workflow. In the slack conversation it looks like a bunch of conversation is around this page: https://github.com/hashicorp/web-unified-docs/blob/main/content/terraform-docs-common/docs/cloud-docs/api-docs/index.mdx. So let's base our partial then remove content Plugin workflow tests around that page.

// This ensures exclusion directives in global partials are properly evaluated
.use(remarkIncludePartialsPlugin, { partialsDir, filePath })

// Only apply content exclusion if this is NOT a global partial
Copy link
Contributor

Choose a reason for hiding this comment

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

@williamdalessandro are we sure about this? It sounds like they want content exclusion in global partials: https://app.asana.com/1/90955849329269/task/1211058606978186/comment/1211471674451585?focus=true.

Double check with Sarah here; as I am not 100% sure on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's ask Sarah for a test case here, so we can double check that we understand their needs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Everything else in this PR looks great. 🎉

We just need to double check this before approval.

Copy link
Contributor

@RubenSandwich RubenSandwich left a comment

Choose a reason for hiding this comment

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

Looks great @williamdalessandro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vault Content update for Vault product docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants