Skip to content

Conversation

@lennessyy
Copy link
Contributor

@lennessyy lennessyy commented Sep 12, 2025

Previous implementation of de-indenting was flawed. It would de-indent every line in the whole Markdown file if turned on - including lists and other text that we don't want to de-indent. This was not caught in the test cases since the entire test case only had a code snippet but no preceding or succeeding lines.

  • Added new functions that identify the minimum indentation in the snippet and only remove that much from the code block
  • Adjusted test cases
  • I changed the default on code dedenting to true, but it can still be turned off if it is causing problems.

See the results in the diffs of this PR: https://github.com/temporalio/documentation/pull/3840/files

@lennessyy lennessyy changed the title fix: Fix dedenting flag fix: fix dedenting feature Sep 12, 2025
@lennessyy lennessyy requested a review from axfelix September 12, 2025 18:10

config.enable_source_link =
extracted?.enable_source_link ?? true
? current.enable_source_link
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fancy looking but I thought it was too hard to read

for (const file of files) {
await writeAsync(
file.fullpath,
file.fileString(this.config.features.enable_code_dedenting)
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 removed the old dedenting implementation to avoid confusing.

if (config.select !== undefined) {
const selectedLines = selectLines(config.select, this.lines, this.ext);
lines.push(...selectedLines);
let snippetLines = selectLines(config.select, this.lines, this.ext);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where we assemble the lines of the snippet and where I run the lines through the dedenting functions

Copy link
Contributor

@axfelix axfelix left a comment

Choose a reason for hiding this comment

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

Excellent and thorough changes!

@lennessyy lennessyy merged commit fc88543 into main Sep 18, 2025
1 check passed
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.

3 participants