diff --git a/scripts/prebuild/mdx-transforms/build-mdx-transforms.test.mjs b/scripts/prebuild/mdx-transforms/build-mdx-transforms.test.mjs index 2d70aeb9b6..16e7a4ca4b 100644 --- a/scripts/prebuild/mdx-transforms/build-mdx-transforms.test.mjs +++ b/scripts/prebuild/mdx-transforms/build-mdx-transforms.test.mjs @@ -1396,5 +1396,69 @@ Common documentation. expect(output).toContain('Common documentation') expect(output).not.toContain('@include') }) + + test('should remove TFEnterprise:only block with JSX/MDX element partial (Note component)', async () => { + // Clear any existing mocks to use real PRODUCT_CONFIG + vi.restoreAllMocks() + + // Real terraform-docs-common has versionedDocs: false, so no version directories + const mockVersionMetadata = { + 'terraform-docs-common': [ + { version: 'v0.0.x', releaseStage: 'stable', isLatest: true }, + ], + } + + // Partial containing MDX/JSX element (Note component) - matches beta/explorer.mdx + const partialContent = ` + +This feature is in beta. We recommend only using it non-production environments because updates during the beta phase may require you to destroy the explorer database. Running the explorer may increase the load on the Terraform Enterprise server in unexpected ways, resulting in slowdowns or outages. + +Explorer on Terraform Enterprise only has access to the information available in the runs from Terraform Enterprise 1.0.0 and later. +You can provide feedback on this feature by selecting **Give Feedback** from the **Actions** menu or by contacting your account team. + + +` + + const mainContent = `--- +page_title: HCP Terraform explorer for workspace visibility +description: >- + Learn how to find data about your resource, module, and provider usage across + workspaces and projects in HCP Terraform with the explorer for workspace + visibility. +--- +# Explorer for workspace visibility + + +@include 'beta/explorer.mdx' + + +As your organization grows, keeping track of your sprawling infrastructure estate can get increasingly more complicated. The explorer for workspace visibility helps surface a wide range of valuable information from across your organization. +` + + vol.fromJSON({ + '/content/terraform-docs-common/docs/cloud-docs/workspaces/explorer.mdx': + mainContent, + '/content/terraform-docs-common/docs/partials/beta/explorer.mdx': + partialContent, + }) + + await buildMdxTransforms('/content', '/output', mockVersionMetadata) + + const output = fs.readFileSync( + '/output/terraform-docs-common/docs/cloud-docs/workspaces/explorer.mdx', + 'utf8', + ) + + // TFEnterprise:only content should be completely removed in terraform-docs-common + expect(output).not.toContain('') + expect(output).not.toContain('') + expect(output).not.toContain('This feature is in beta') + expect(output).not.toContain('Explorer on Terraform Enterprise') + expect(output).not.toContain('TFEnterprise:only') + + // Content after the block should be preserved + expect(output).toContain('As your organization grows') + expect(output).toContain('infrastructure estate') + }) }) }) diff --git a/scripts/prebuild/mdx-transforms/exclude-content/ast-utils.mjs b/scripts/prebuild/mdx-transforms/exclude-content/ast-utils.mjs index 84419fb96e..caeda018a0 100644 --- a/scripts/prebuild/mdx-transforms/exclude-content/ast-utils.mjs +++ b/scripts/prebuild/mdx-transforms/exclude-content/ast-utils.mjs @@ -12,11 +12,12 @@ const END_RE = /^(\s+)?(\s+)?$/ // Helper to check if a node is a comment node (jsx, html, or code containing HTML comment) // Remark sometimes parses indented HTML comments as code nodes instead of jsx nodes function isCommentNode(node) { - if (node.type === 'jsx' || node.type === 'html') { - return true - } // Check if it's a code node containing an HTML comment - if (node.type === 'code' && node.value) { + if ( + (node.type === 'code' && node.value) || + node.type === 'jsx' || + node.type === 'html' + ) { return ( node.value.trim().startsWith('') ) diff --git a/scripts/prebuild/prebuild-arm-linux-binary.gz b/scripts/prebuild/prebuild-arm-linux-binary.gz index ad13b23f1d..68ba13e85d 100755 Binary files a/scripts/prebuild/prebuild-arm-linux-binary.gz and b/scripts/prebuild/prebuild-arm-linux-binary.gz differ diff --git a/scripts/prebuild/prebuild-arm-mac-binary.gz b/scripts/prebuild/prebuild-arm-mac-binary.gz index 984113df98..c3f16f2682 100755 Binary files a/scripts/prebuild/prebuild-arm-mac-binary.gz and b/scripts/prebuild/prebuild-arm-mac-binary.gz differ diff --git a/scripts/prebuild/prebuild-x64-linux-binary.gz b/scripts/prebuild/prebuild-x64-linux-binary.gz index c41b022380..95973f3cb9 100755 Binary files a/scripts/prebuild/prebuild-x64-linux-binary.gz and b/scripts/prebuild/prebuild-x64-linux-binary.gz differ