Skip to content

Add a preference to use the latest version of a documentation - #2734

Merged
simon04 merged 4 commits into
mainfrom
latest-version-preference
Sep 14, 2026
Merged

simon04 merged 4 commits into
mainfrom
latest-version-preference

Conversation

@simon04

@simon04 simon04 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Closes #744.

Adds a single preference, Automatically switch to the latest version of a documentation (off by default), next to the offline download option in the General section of the preferences. It is not per documentation.

With it enabled, App#migrateToLatestVersions runs at boot, right after migrateDocs and before the docs are loaded: every enabled doc for which a newer version is available is disabled, and that newer version is enabled in its place. Enabling CMake 3.9 today therefore switches to CMake 3.10 once it is released.

Details:

  • Versions are compared segment-wise as numbers (Doc#isNewerVersionThan), so 3.9 < 3.12 and 9 < 10.
  • Only numbered versions take part. Docs that share a name but are variants rather than versions are left alone: node~10_lts ("10 LTS"), gcc~7_cpp ("7 CPP"), the Haxe targets, tensorflow~guide, openjdk~8_web.
  • An empty version means the doc holds the latest version (angular, node, webpack) and outranks any number.
  • When the latest version is already enabled, the older one is only disabled.
  • saveDocs bumps the database schema, so onUpgradeNeeded drops the object store of the superseded doc — its offline data is cleaned up just like when it is disabled by hand.

Tested with test/assets/doc_version_test.js (node --test test/assets/), covering the version comparison, the variants that must not migrate, and the three migration paths.

Enabling it replaces, at boot, every enabled doc for which a newer version
is available with that version, so that e.g. CMake 3.9 becomes CMake 3.12
once it is released.

Only numbered versions are migrated; variants that share a name, such as
Node.js 10 LTS or the Haxe targets, can't be ordered and are left alone.
An empty version means the doc holds the latest version and outranks any
number. saveDocs bumps the database schema, which drops the object store
of the superseded doc just like disabling it manually does.

Closes #744
@simon04
simon04 requested a review from a team as a code owner September 14, 2026 07:28
@simon04 simon04 self-assigned this Sep 14, 2026
@simon04
simon04 requested a balanced review from Copilot September 14, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Migration can delete a working offline version before confirming that its replacement loads successfully.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds an opt-in preference that migrates enabled documentation to its latest numbered version during startup.

Changes:

  • Adds version comparison and migration logic.
  • Adds the preference to settings and UI.
  • Adds migration and version-selection tests.
File summaries
File Description
assets/javascripts/app/app.js Runs and persists version migrations.
assets/javascripts/app/settings.js Defines the new preference.
assets/javascripts/models/doc.js Implements version detection and comparison.
assets/javascripts/templates/pages/settings_tmpl.js Adds the preference checkbox.
assets/javascripts/views/content/settings_page.js Exposes the preference to the template.
test/assets/doc_version_test.js Tests comparison and migration behavior.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread assets/javascripts/app/app.js Outdated
saveDocs bumps the database schema, which drops the object store of the doc
that is disabled. Swapping before the index of the latest version is known to
load left a boot that fails, e.g. an offline one, with neither the version
that was installed nor the one that replaced it.

The index is now loaded first and the swap is made in its success callback,
so a doc that can't be fetched stays enabled and nothing is persisted.
Awaiting the index of the latest version reads better than chaining the
migrations through callbacks, and bootAll can wait for them before loading
the enabled docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Serial index loading can significantly delay startup when migrating several documentation sets.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread assets/javascripts/app/app.js Outdated
Comment on lines +212 to +218
const loaded = await new Promise((resolve) =>
latest.load(
() => resolve(true),
() => resolve(false),
{ readCache: true, writeCache: true },
),
);
Awaiting one index after the other delayed the boot of everyone whose docs
are several releases behind. The indexes are now loaded through as many
parallel requests as Docs#load makes, and a version superseding more than one
enabled doc is only loaded once.
@simon04
simon04 merged commit 6f8f80b into main Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An option to automatically use latest version of documentation

2 participants