Skip to content

fix: support re-aggregating docforge output as input (round-trip)#486

Merged
gardener-prow[bot] merged 3 commits into
masterfrom
fix/reaggregation-roundtrip
Jul 22, 2026
Merged

fix: support re-aggregating docforge output as input (round-trip)#486
gardener-prow[bot] merged 3 commits into
masterfrom
fix/reaggregation-roundtrip

Conversation

@klocke-io

@klocke-io klocke-io commented Jul 21, 2026

Copy link
Copy Markdown
Member

How to categorize this PR?

/kind enhancement

What this PR does / why we need it:

Unblocks feeding already-transformed, committed docforge output back into docforge (round-trip). Two independent fixes:

  • Fix A — root-absolute links: Root-absolute links (e.g. /docs/x.png) emitted by a previous run were resolved against the repo root on re-aggregation, dropping the prefix docforge stripped during the original aggregation. Embedded images hard-failed, normal links only warned. New ReAnchorRootAbsolute reconstructs the stripped prefix deterministically from the source resourcePath up to and including the first configured structural dir; both link callers apply it before ResolveRelativeLink. URL.ResolveRelativeLink is untouched.
  • Fix B — frontmatter protection: editThisPage overwrote origin-identity frontmatter (github_repo, github_subdir, path_base_for_github_subdir, params.github_branch) that a re-aggregated file already carried. MergeDocumentAndNodeFrontmatter now keeps an already-present source-file value field-wise (original wins). weight/prev/next keep refreshing as they describe the current site tree, not origin identity.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

  • TDD: unit + integration tests written first (reanchor_test.go, document_worker_test.go, frontmatter_test.go); the integration test reproduces the original embed hard-fail blocker.
  • Verified end-to-end
  • docsy plugin left unchanged; the guard lives in MergeDocumentAndNodeFrontmatter, the only place with both frontmatters.

Release note:

Support re-aggregating docforge output as input: root-absolute links are re-anchored to their original prefix, and origin-identity frontmatter fields survive re-aggregation.

Root-absolute links (e.g. /docs/x.png) emitted by a previous docforge run
were resolved against the repo root on re-aggregation, dropping the prefix
that was stripped during the original aggregation. Embedded images hard-failed,
normal links only warned.

ReAnchorRootAbsolute reconstructs the stripped prefix deterministically from
the source resourcePath up to and including the first configured structural
dir, and both link callers apply it before ResolveRelativeLink.
editThisPage overwrote origin-identity frontmatter (github_repo, github_subdir,
path_base_for_github_subdir, params.github_branch) that a re-aggregated file
already carried from its original aggregation.

MergeDocumentAndNodeFrontmatter now keeps an already-present source-file value
field-wise (original wins). weight/prev/next keep refreshing as they describe
the current site tree, not origin identity.
@gardener-prow gardener-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. labels Jul 21, 2026
The package-level var tripped the gochecknoglobals linter. The keys are
read in a single place, so scope them locally instead. Also drops the
numbered case comments in the reanchor table test (Entry names describe them).
@klocke-io
klocke-io requested a review from VelmiraS July 21, 2026 13:05
@VelmiraS

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@gardener-prow gardener-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2026
@gardener-prow

gardener-prow Bot commented Jul 21, 2026

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: d3d9b557a95d68f1b87229982f9cdfba0967d98a

@VelmiraS
VelmiraS marked this pull request as ready for review July 21, 2026 14:27
@gardener-prow gardener-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 21, 2026
@klocke-io klocke-io added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 22, 2026
@gardener-prow

gardener-prow Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: VelmiraS

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gardener-prow
gardener-prow Bot merged commit ed27b1c into master Jul 22, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants