Repository navigation
Docs: Improve XML binding documentation - #167
Merged
Merged
Conversation
This is done so later commits can e.g. add IDE autocompletion support. Written with Claude.
It is usually outdated anyways and better generated for the documentation pages. Written with Claude.
It missed a few tags due to e.g. templating and it had some tags multiple times. Written by Claude.
- Trajectories: the rk86 example used the kstraj_integrator_rk65 tag - Objects: the short command member form (add_control, ...) is only available inside ksgeo_space/side/surface; add_trajectory does not exist (set_trajectory does), and fix the child name typo - Generators: ksgen_value_radius_* document radius_min/radius_max (not value_min/value_max); spherical variant said "cylindrical" - ElectricFields/MagneticFields/Fields: remote_sourcepoint_start/end, show_plot and iterations_between_restarts were misspelled - MagneticFields/ElectricFieldExplicitSuperposition: document the add_field/component child elements in an "elements:" section with nested "parameters:", like the other files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Written with Claude.
Commands acting on a root object (terminators, fields, interactions, step modifiers, trajectory) may omit the parent attribute; this was only documented in a comment of the Complete XML files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file in Shapes/Complex/Source was an identical, uncompiled copy of Bindings/Shapes/Complex/Source/KGComplexAnnulusBuilder.cc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
migrate_xml_docs.py attaches the documentation comments of annotated XML files to the documented elements (resolving their C++ types via the binding tree) and inserts them as //! comments above the builder typedefs and attribute/child registrations. It shows a plan by default, applies it with --apply (optionally clang-formatting only the changed lines), and verifies the result against a re-extracted JSON with --check. extract.py: a //! comment documents the registration that starts directly below it (the first one if several share the line), so that comments stay attached after clang-format joins lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated with:
Scripts/bindings/extract.py Kassiopeia KEMField KGeoBag Kommon -o bindings.json
Scripts/bindings/migrate_xml_docs.py bindings.json \
Kassiopeia/XML/Complete/{Generators,Geometry,Interactions,Navigators,Objects,Terminators,Trajectories,Writers}.xml \
KEMField/Source/XML/Complete/*.xml --apply --format
(Kassiopeia/XML/Complete/Fields.xml is deprecated and only documents
legacy aliases of the KEMField fields, so it is not migrated.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iles Texts like "listed above", "see below" or "at the top of this file" referred to the position in the Complete XML files and no longer make sense next to the C++ bindings. Also move the note on Mott scattering from ksint_scattering to calculator_mott, combine the descriptions of the inline and condensed ksint_scattering forms, and show the whole chain in the output component example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Their documentation now lives in //! comments next to the C++ bindings and is shown in the generated bindings documentation. - Delete the annotated catalogue files in Kassiopeia/XML/Complete and KEMField/Source/XML/Complete, including the deprecated Fields.xml - Keep ElectricFieldExplicitSuperposition.xml and ElectricFieldDiscreteAxial.xml, which are complete working setups, as examples in KEMField/Source/XML/Examples (installed to config/KEMField/Examples) - Drop the "Complete" install rules (Geometry and Navigators installed no files there) - Point the KEMField field docs to the bindings documentation - Mark the legacy ksfield_* aliases as @deprecated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This replaces the old complete XML files.
The "Torus Surface" section showed the cut torus example and vice versa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the usage guide - Docstrings (//! comments) are now reStructuredText. The ten existing texts that relied on line breaks are rewritten as proper lists. - New @image tag: path relative to the repository root, shown at its position in the description; extract.py fails if the file is missing. - Sphinx extension _ext/xml_bindings.py with the xml-element directive, which renders an element's documentation (description, images, child elements, attributes, examples) e.g. in the usage guide, and links the reference pages back to the places where it is used. - migrate_rst_docs.py moves element documentation from hand-written pages into the C++ docstrings and replaces it by the directive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated with:
Scripts/bindings/extract.py Kassiopeia KEMField KGeoBag Kommon -o bindings.json
Scripts/bindings/migrate_rst_docs.py bindings.json \
Documentation/gh-pages/source/kgeobag_simple_shapes.rst --apply --format
The page keeps its structure; each shape section now renders the
documentation from the C++ sources with the xml-element directive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skip structural sections, add --assign Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e binding docstrings
Generated with:
Scripts/bindings/extract.py Kassiopeia KEMField KGeoBag Kommon -o bindings.json
D=Documentation/gh-pages/source
Scripts/bindings/migrate_rst_docs.py bindings.json \
$D/kgeobag_complex_shapes.rst $D/kassiopeia_navigation.rst $D/kassiopeia_simulation.rst \
--assign $D/kgeobag_complex_shapes.rst:18=port_housing_surface \
--assign $D/kgeobag_complex_shapes.rst:42=conic_section_port_housing_surface \
--assign $D/kgeobag_complex_shapes.rst:248=port_housing_space \
--assign $D/kgeobag_complex_shapes.rst:268=conic_section_port_housing_space \
--assign $D/kassiopeia_navigation.rst:39=ksnav_meshed_space \
--assign $D/kassiopeia_simulation.rst:1=ks_simulation \
--apply --format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge pages "See the above rod surface", "outlined above" or "see below" referred to the order of sections on the usage pages; they now link to the respective elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In HTML output, opening and closing tags in all XML examples link to the documentation of their elements, resolved along the nesting of the example. Element pages list where the element appears in the documentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Element pages list the example configurations (Kassiopeia/XML, and the KEMField and KGeoBag examples) that use the element, one per line. Examples described in the documentation come first, are enclosed in <> and link to their description; the others link to the file on GitHub. "Appears in the documentation" entries are also listed one per line. Also name the file in "The Mesh Simulation Example" like in the other example sections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shortened "Kassiopeia/Examples/..." names were neither source nor installed paths. Installed paths can coincide (the VTK variants replace the plain Kassiopeia examples), so the full source path is shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The theme prevents line breaks in table cells; for the generated binding tables, the description column now wraps and the table uses the full width. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Links to the usage guide, documentation pages and example configurations (and on usage pages the link to the reference page) are now shown in a "More information" block at the end of an element's documentation, which is only shown if it has content. "Defined in" stays at the top, and the "No description available." placeholder is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The graphs only showed information that the element reference pages contain as well, were too large to read (about 400 elements) and were incomplete. Removing them also removes GraphViz from the bindings generation (it stays installed for the graphviz diagrams in the docs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bindings were only read from files named *Builder, which missed e.g. the attributes of <file> (Kommon/Core/File/KTextFile) and <kasper>. Now all C++ files defining bindings are read, but only if they are part of the build (referenced in a CMakeLists.txt): the uncompiled KSCommandGroupBuilder, the *_old interaction calculators and KSOutput.h are skipped with a warning (--all-files includes them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe how the file location is determined from path/base and their defaults, and that <messages> sets its own defaults for the log file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
name behaves exactly like base, and <messages> overwrites the defaults of its log file, so default_path and default_base have no effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
extract.py detects attributes naming other objects: values resolved with KToolbox::Get<T> or KGInterface::Retrieve* in the builder (also via a member that is looked up later, e.g. in End()), and //! @reference <type> annotations. It also records the base classes of each element type and, for data wrapper builders, the type of the object they create. The reference pages show for such attributes which elements they can refer to (or the KGeoBag path they expect), and list on each element the attributes that can refer to it. Also resolve C++ type aliases of element types: the attributes of <electrostatic_dirichlet> and <electrostatic_neumann> were attached to an invisible duplicate element because their builders use a typedef. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The builder only looks up these attributes as generic KSComponent and passes them to the root objects, so their actual types are annotated with @reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
extract.py collects the string literals an attribute value is compared with in the builder's AddAttribute (comparisons against prefixes mark the list as open), and the new //! @values tag gives them by hand. The attribute tables show the values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The names are only checked in KElectrostaticBoundaryIntegratorFactory, so they are given with @values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
extract.py matched registrations inside comments, so e.g. the commented-out magnetostatic_dirichlet/magnetostatic_neumann elements were documented. Code is now matched with comments blanked out (keeping positions); //! documentation comments are read as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This is sorely needed, and the improvement is substantial! Even if Claude has made hallucinated some small mistakes in descriptions (I don't know if there are any, but I'm not looking through 300 files to check!), the previous documentation was so bad that this will be fine for now. We can patch any spotted mistakes afterwards. LTGM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed with Daniel C. and @richeldichel , I used Claude to improve the XML documentation significantly.
Before: https://katrin-experiment.github.io/Kassiopeia/bindings.html
This PR: https://2xb.github.io/Kassiopeia/bindings.html
All tags in examples in the documentation are now links to specific descriptions of these tags. All tags have own pages, documenting their relation to the entire configuration. And they link examples and documentation.
This is also done so as a next step, one could add IDE autocompletion and syntax checking using the same intermediate representation model developed for this documentation.
Fixes #106 .