Skip to content

mcgui/mxgui: show parameter docs in Insert Component dialog again - #3218

Merged
willend merged 1 commit into
mainfrom
componentparser-docs
Nov 28, 2026
Merged

willend merged 1 commit into
mainfrom
componentparser-docs

Conversation

@willend

@willend willend commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Free-form text area

The Insert Component dialog in mcgui and mxgui has shown no parameter descriptions since 028b69f (Oct 2025, first in v3.5.38). In ComponentParser.__matchDocStringsToPars, the pattern ^(.*)([\[\w\s\]])(.*)$ takes the whole line except its last character as the parameter name, so no name ever matched.

Fix in mccodelib/utils.py:

  • ComponentParser now takes the parameter docs from parse_header, the parser that mcdoc and mccode-check-doc-params use. The first entry wins, as in mcdoc, and the text is shown as [unit] doc. The old matcher and its helper are removed.
  • A parameter without a default value kept its type in the name (string filename), so it never matched a doc either. The type is now split off. This affected 25 components.

Tests (macOS arm64, mccode-dev env):

  • ComponentParser on all 661 McStas and McXtrace components: all parse, and every parameter has a description (before: none had one).
  • The dialog rendered offscreen with the old and the new utils.py (mxgui Mirror_toroid, mcgui Text). Before: all descriptions blank, and Text's first label reads string text:. After: text: with [str] Text to draw., and every other parameter shows its description too.

Not tested: the full GUI run interactively, Linux and Windows.


Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Claude Code (Claude Opus 5.5) found the cause, made the fix and ran the tests. The maintainer directed and reviewed the work.
  • AI-assisted commits must carry a Co-Authored-By line naming the tool, see CONTRIBUTING.md

Development OS / boundary conditions

macOS arm64, micromamba mccode-dev environment.


PR Checklist for contributing to McStas/McXtrace

  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist (Python tooling fix in mccodelib/utils.py)

Tip for reviewers: Visit https://blueblazin.github.io/blockviz/#github=[URL_of_this_PR] for a visual look at code changes

🤖 Generated with Claude Code

ComponentParser matched no parameter docs since 028b69f, so the dialog
showed none. Take them from parse_header, as mcdoc does. Also strip the
type from parameters without a default value ("string filename").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend
willend merged commit b45fb6d into main Nov 28, 2026
16 checks passed
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