Skip to content

Keep the docs layout when --update follows a crashed run - #32

Open
dandydarshan wants to merge 1 commit into
mainfrom
release-2.1.3
Open

dandydarshan wants to merge 1 commit into
mainfrom
release-2.1.3

Conversation

@dandydarshan

Copy link
Copy Markdown
Owner

Problem

A run that stops before writing metadata.json (for example the 2.1.1 Mermaid crash, which moves the old docs and metadata aside first) leaves docs with no recorded layout. On the next --update:

  1. generate picks the default hierarchical layout, because there is no metadata.
  2. IncrementalUpdater calls read_layout(), which treats a missing metadata.json the same as old docs with no layout recorded, so it returns flat and switches config.layout to flat.
  3. The 2.1.2 resume path then writes the missing pages flat, and organize_docs moves the existing pages out of their folders.
  4. metadata.json records "layout": "flat", so every later --update stays flat.

Fix

  • read_layout returns the default layout when metadata.json is missing. Metadata that exists but has no layout is still read as old flat docs.
  • IncrementalUpdater keeps the run's layout when there is no metadata.json, so --flat is still respected.

Docs that were already turned flat this way go back into folders with one plain codewiki generate (without --update). That is in the changelog entry, under Unreleased.

Tests

  • New test_docs_without_metadata_keep_the_run_layout. It fails without the fix.
  • test_read_layout_defaults_to_flat_for_old_docs and test_updater_pages_follow_recorded_layout now model old docs as a metadata.json without a layout instead of no metadata at all.
  • Full suite: 884 passed.

Version not bumped: this waits in Unreleased for more fixes before 2.1.3.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CXRqenV27WmHS3PtveCubG

A run that stopped before writing metadata.json left docs with no recorded
layout. read_layout treated that as old flat docs, so the updater switched
the run to flat, moved existing pages out of their folders and recorded the
flat layout for every later update.

read_layout now returns the default layout when metadata.json is missing
(metadata without a layout is still old flat docs), and the updater keeps
the run's layout in that case so --flat is respected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CXRqenV27WmHS3PtveCubG

This branch has not been deployed

No deployments
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.

1 participant