Skip to content

docs: package-wide docstring standardization - #488

Merged
lkdvos merged 5 commits into
mainfrom
docs/docstrings
Aug 2, 2026
Merged

docs: package-wide docstring standardization#488
lkdvos merged 5 commits into
mainfrom
docs/docstrings

Conversation

@lkdvos

@lkdvos lkdvos commented Jul 30, 2026

Copy link
Copy Markdown
Member

Docstring standardization slice of #449, re-applied on top of current main: a new docs/DOCSTRING_STYLE.md and its conventions applied to 53 files under src/ — unified bullets and argument lists, a fixed section order, $(TYPEDEF)/$(TYPEDFIELDS) for algorithm structs, @extref links to upstream APIs, driver ↔ algorithm cross-links, and runnable jldoctest examples on the main entry points.

Documentation-only. Stripping docstrings and comments from every touched src/ file and diffing against main gives an empty result — no code changed. The three genuine code changes hiding in #449's src/ diff went to #489 instead.

Two things beyond the style pass:

  • src/utility/plotting.jl linked (@ref entanglement_spectrum), an anchor that exists nowhere; since lib/lib.md autodocs the whole module, this fails the build. Retargeted at the real entanglement_spectrum docstring.
  • The source branch predates Replace trscheme by trunc #482 (trschemetrunc) and Refactor MPSTensor construction to fix type piracy #475 (removed MPSTensor constructors), so it was applied as a patch keeping main's code; the affected docstrings and one jldoctest were rewritten accordingly.

Also adds two mpskit.bib lines these docstrings need: the gleis2023 entry, and the Hubig2015hubig2015 rename with its @cite. Expect a one-line conflict with #487 on that key; take lowercase.

Doctests pass and the Documenter half of the build is clean; the vitepress build step can't run on my machine (host glibc too old for rollup), so CI should confirm the HTML render.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/algorithms/ED.jl 100.00% <ø> (ø)
src/algorithms/approximate/approximate.jl 56.00% <ø> (ø)
src/algorithms/approximate/zipup.jl 97.22% <ø> (ø)
src/algorithms/changebonds/changebonds.jl 91.30% <ø> (ø)
src/algorithms/changebonds/optimalexpand.jl 98.85% <ø> (ø)
src/algorithms/changebonds/randexpand.jl 63.63% <ø> (ø)
src/algorithms/changebonds/sketchedexpand.jl 98.43% <ø> (ø)
src/algorithms/changebonds/svdcut.jl 89.18% <ø> (ø)
src/algorithms/changebonds/vumpssvd.jl 100.00% <ø> (ø)
.../algorithms/derivatives/hamiltonian_derivatives.jl 93.30% <ø> (ø)
... and 45 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos added the documentation Improvements or additions to documentation label Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

After the build completes, the updated documentation will be available here

lkdvos and others added 4 commits August 1, 2026 22:03
Write down the conventions the package-wide docstring pass applies: section
headings, `- name::Type: description` argument lists, cross-linking with `@ref`
/ `@extref`, `@cite` references, and how algorithm types document their fields
and constructors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`SketchedExpand`'s docstring cites the controlled-bond-expansion paper, so add
the corresponding bibliography entry. Rename the one capitalised citation key
to `hubig2015` for consistency with every other key in the file, and update the
`@cite` in `DMRG3S` to match.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Prose and formatting pass over every docstring in `src/`, following
`docs/DOCSTRING_STYLE.md`:

- unify bullet markers on `-` and argument lists on `- name::Type: description`
- promote `##` section headings to `#`, and order them consistently
  (signature, description, arguments, keywords, returns, examples, see-also,
  references)
- switch algorithm types to `$(TYPEDEF)`/`$(TYPEDFIELDS)` with per-field
  docstrings, and document their constructors under `# Constructors`
- add `Used as the ... argument of [...](@ref)` cross-links so algorithm types
  point back at the driver they plug into
- link upstream API with `[text](@extref Pkg.name)` (KrylovKit,
  MatrixAlgebraKit, TensorOperations) instead of naming it in plain text
- normalise spacing in type parameters and keyword defaults
  (`PeriodicArray{T,1}` -> `PeriodicArray{T, 1}`, `side=:both` -> `side = :both`)
- add `@cite` references where an algorithm has a canonical paper
- new or substantially expanded docstrings for the quasiparticle state types,
  the finite environment types, and several driver functions, with runnable
  `jldoctest` examples on the main entry points

Also drop a link to a non-existent `entanglement_spectrum` anchor in
`entanglementplot`, retargeting it at the `entanglement_spectrum` docstring.

This commit changes documentation only. Verified by stripping docstrings,
comments and blank lines from both `origin/main`'s version and this one of every
touched file and diffing the results, which is empty.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ansion `trunc`

Three follow-ups to the package-wide docstring pass:

- Replace the remaining uses of "enrich" with the package's own bond-expansion
  vocabulary, matching `alg_expand`/`changebond!`/`OptimalExpand`.

- Format the code inside docstrings with Runic. Every fenced `julia`/`jldoctest`
  block was already clean; the drift was in the indented signature blocks. Enable
  `--docstrings` in the pre-commit hook so this stays enforced locally, and
  hand-fix the blocks Runic silently skips (docstrings with `$(TYPEDEF)`
  interpolation, and blocks that are not parseable Julia). Note that CI cannot
  enforce this: the shared QuantumKitHubActions FormatCheck workflow runs plain
  `git runic --diff` and takes only a `julia-version` input, so the hook is
  deliberately stricter than the CI check.

- Spell out that the `trunc` of `OptimalExpand`, `RandExpand` and `SketchedExpand`
  bounds how many directions are *added* to each bond, not the total bond
  dimension that is kept -- the opposite of what the same keyword means on
  `SvdCut` and on the drivers. It is applied to the orthogonal complement (or, for
  the randomized expanders, to random weights), so `truncrank`/`truncspace` are
  the strategies with a robust meaning there.

Also fixes the `MPO` docstring naming its type parameter `O` where the struct
declares `TO`, a "this is happens" typo, `RandExpand` prose that described only
the infinite code path, and the double-hash section headers plus section order in
the `Zipup` docstring.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lkdvos
lkdvos marked this pull request as ready for review August 2, 2026 12:38
- `exact_diagonalization`: drop the documented `len` keyword. The function takes
  no such keyword -- it derives `L = length(H)` internally -- so passing it would
  be a `MethodError`. The documented signature now matches the definition exactly.

- `ChepigaAnsatz2`: move the hand-written `# Fields` bullets onto the struct as
  per-field doc strings rendered by `$(TYPEDFIELDS)`, matching `ChepigaAnsatz`
  and template A1. The defaults stay in the field strings, since the fields are
  positional and the constructor supplies them.

- Drop the "Physics claims" section from the style guide. The `<!-- REVIEW -->`
  convention it described does not work in a docstring: DocumenterVitepress
  escapes HTML comments, so they render as visible body text on the page. Record
  that as an "Attachment" rule instead, next to the docstring-detaching comment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lkdvos
lkdvos merged commit e660f46 into main Aug 2, 2026
30 checks passed
@lkdvos
lkdvos deleted the docs/docstrings branch August 2, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant