Skip to content

Resolve tested snippets and keep only mongosh content when reading pages - #4570

Open
evanchooly wants to merge 1 commit into
audits-bits-seedfrom
audits-snippets
Open

evanchooly wants to merge 1 commit into
audits-bits-seedfrom
audits-snippets

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Step 5 of the operator-audit plan: the snippet resolver, listed as the largest remaining unlock. Stacked on #4569.

Problem

The example inventory skipped 103 of 300 operator pages, most of the stage pages among them:

  • Tested snippets. Their examples live in MongoDB's tested snippets. For example, $median has
    .. io-code-block::
       .. input:: /code-examples/tested/command-line/mongosh/aggregation/accumulators/median/median-rating-by-year.js
       .. output:: /code-examples/tested/.../median-rating-by-year-output.sh
    and the legacy extractor refused any directive with a target ("External snippet requires a source resolver").
  • Other drivers' content. Pages lay out each driver in a .. tabs-drivers:: set or a composable tutorial's .. selected-content:: blocks. The C# tab's remote shared includes (.. sharedinclude:: dbx/csharp/...) merged into the example and were rejected, which took the shell example down with them.

Discovery couldn't see new or renamed examples on those pages, and generation couldn't consider them.

Change

  • FormMigration.shellTabs keeps only the mongosh content: the shell tab of each .. tabs-drivers:: set, and the .. selected-content:: blocks selected for shell, each re-indented to its directive. Every drivers-tab set in the manual has a shell tab.
  • FormMigration.snippets splices in the files that .. input::, .. output:: and .. literalinclude:: name under /code-examples/ or /includes/ as inline blocks:
    • source/code-examples/tested is a repository symlink to ../../../../code-examples/tested, so snippets are read from content/code-examples;
    • each file is recorded with its git blob among the page's includes, so provenance survives without the page;
    • the directives' options stay, since they only style the output. The only ones in the manual are :language:, :category:, :copyable:, :visible: and :emphasize-lines:; nothing selects lines;
    • a target that isn't in the checkout is left in place, and .. segments are refused.
  • Fetching: fetch.py pages follows those targets. The discovery workflow and the README's clone add /content/code-examples/tested/ (9.2 MB) to the sparse checkout.
  • The regenerated inventory is committed in this PR, at the same docs commit e4b0c153. Otherwise the first weekly run would treat every newly visible unowned example as new and file a NEW_EXAMPLE issue for each.

Result

Before After
Pages read 197 297
Pages skipped 103 3 (the non-operator interface, search, searchMeta)
Examples owned 300 433
Unowned 32 115
Unnamed / ambiguous 11 / 0 30 / 4
  • No example on the 197 pages read before changed status.
  • Generation output is unchanged. The newly visible unowned examples are on stage pages, which aren't a generated family yet, or are gaps: 29 blocked on a $match binding and 5 on $unwind. The weekly job will file those as MISSING_BINDING issues.
  • audits/discover.sh from this commit reproduces the committed inventory byte for byte (inventory.diff is empty).

Decisions for review

  • mongosh only. Other drivers' tabs are dropped rather than parsed. The audits compare against mongosh, and those tabs show the same example in C#/Node.
  • Sample datasets. Many tested snippets query MongoDB's sample datasets (db.movies from sample_mflix) and print elided results (_id: ..., trailing ...). They extract like any other example, and generation will report them as gaps; the runner doesn't load sample datasets. Of 303 mongosh snippet inputs, 186 read a sample dataset.

Verification

  • New SnippetsTest: shell-tab and selected-content selection, snippet and include splicing with blobs, an absent target left in place, and .. refused.
  • Audits suite: 455 pass under Critter, then reflection.

Self-reviewed only: the independent reviewers are out of quota until 2026-11-26.

103 operator pages were skipped: their examples are tested snippets that
io-code-block and literalinclude directives name, or sit beside other
drivers' tabs whose remote shared includes the extractor rejected. Page
reading now keeps only the shell tab of each tabs-drivers set and the
selected-content chosen for shell, then splices in the named snippet and
include files, recording each with its blob. fetch.py pages follows
those targets and the discovery clone includes the snippet tree.

The inventory at the same docs commit now reads 297 pages; no example on
the pages read before changed, and generation is unchanged.

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