Skip to content

ci: check OPTIONS.rst freshness#6940

Open
MukundaKatta wants to merge 2 commits into
trezor:mainfrom
MukundaKatta:codex/check-options-rst
Open

ci: check OPTIONS.rst freshness#6940
MukundaKatta wants to merge 2 commits into
trezor:mainfrom
MukundaKatta:codex/check-options-rst

Conversation

@MukundaKatta
Copy link
Copy Markdown

Description

  • add an options_check target that regenerates python/docs/OPTIONS.rst and fails if it changes
  • include the target in gen_check, so the existing Prebuild checks workflow catches stale CLI docs
  • refresh the currently stale OPTIONS.rst baseline with the same two generated entries as chore(docs): update OPTIONS.rst #6937, so this check can start green even if this PR merges first

Fixes #6938

Testing

  • git submodule update --init --recursive vendor/ts-tvl
  • uv run make options_check
  • git diff --cached --check

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

Walkthrough

This PR adds a Python-side documentation check and integrates it into the repository verification flow. The generator script python/helper-scripts/make-options-rst.py was refactored to accept --output and use pathlib; python/Makefile gained a doc_check target that diffs generated OPTIONS.rst against docs/OPTIONS.rst; the top-level Makefile now invokes that check via new python_doc and python_doc_check targets and adds python_doc_check to gen_check. The generated python/docs/OPTIONS.rst was updated with two new command entries and a CLI help docstring was added to evolu.index_management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding a CI check to verify OPTIONS.rst freshness.
Description check ✅ Passed The description is mostly complete with clear objectives, testing steps, and issue reference, though it lacks formal PR setup details from the template.
Linked Issues check ✅ Passed The PR fully addresses issue #6938 by implementing a CI check that verifies OPTIONS.rst freshness using the existing generator tool.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the freshness check and updating documentation baselines; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/docs/OPTIONS.rst`:
- Line 316: The index_management click command in
python/src/trezorlib/cli/evolu.py is missing a docstring so its help text is
blank; add a descriptive single-line (or short multi-line) docstring immediately
below the def index_management(...) declaration that explains what the command
does, documents the rotation_index option (e.g., its purpose and that it’s
optional), and briefly states the return value (rotation index as string) so
Click will include this description in generated help and docs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 139032fe-0e4f-4a81-adc8-22cac0004d2d

📥 Commits

Reviewing files that changed from the base of the PR and between 1e27d5d and f455df1.

📒 Files selected for processing (2)
  • Makefile
  • python/docs/OPTIONS.rst

Comment thread python/docs/OPTIONS.rst Outdated
@M1nd3r
Copy link
Copy Markdown
Contributor

M1nd3r commented May 15, 2026

Thanks @MukundaKatta for your contribution. Please, make the following changes in order for the PR to be accepted:

  • Adhere to the codestyle of the Makefile - use make instead of $(MAKE)

  • The "check" command should (ideally) not modify the existing files - it should only return an error in case of failure

  • Organization wise, it would be nice to have the check in the /python Makefile. It could be named doc_check. Then the make -C python doc command could be called from the gen and make -C python doc_check from the gen_check.

@M1nd3r M1nd3r requested review from M1nd3r and removed request for matejcik, obrusvit and romanz May 15, 2026 15:38
@M1nd3r M1nd3r mentioned this pull request May 15, 2026
@MukundaKatta
Copy link
Copy Markdown
Author

Addressed the review feedback in d8ea921:

  • moved the OPTIONS freshness check into python/Makefile as doc_check
  • changed the check path to render into a temp file and diff it, so it does not modify committed docs
  • wired root gen to make -C python doc and gen_check to make -C python doc_check
  • replaced $(MAKE) with make in the new root targets
  • added the index-management CLI docstring and regenerated python/docs/OPTIONS.rst

Validated locally:

  • make -C python PYTHON=.venv/bin/python doc_check
  • make PYTHON=.venv/bin/python python_doc_check
  • uv run --group dev black --check helper-scripts/make-options-rst.py src/trezorlib/cli/evolu.py
  • uv run --group dev flake8 helper-scripts/make-options-rst.py src/trezorlib/cli/evolu.py
  • git diff --check

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
python/helper-scripts/make-options-rst.py (1)

41-45: ⚡ Quick win

Consider validating that the delimiter was found.

The loop reads OPTIONS_RST until it finds DELIMITER_STR, but if the delimiter is never found, the script silently reads the entire file into lead_in and continues. This could lead to unexpected output if the file format changes or the delimiter is accidentally removed.

🛡️ Proposed validation check
 lead_in: list[str] = []
+found_delimiter = False

 with OPTIONS_RST.open() as options_rst:
     for line in options_rst:
         lead_in.append(line)
         if DELIMITER_STR in line:
+            found_delimiter = True
             break

+if not found_delimiter:
+    raise ValueError(f"Delimiter '{DELIMITER_STR}' not found in {OPTIONS_RST}")
+
 output: TextIO
 output = args.output.open("w")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/helper-scripts/make-options-rst.py` around lines 41 - 45, The loop
that reads OPTIONS_RST into lead_in stops only when DELIMITER_STR is seen, but
currently doesn't detect the case where the delimiter is missing; update the
reader logic that iterates over OPTIONS_RST so after the loop you check whether
any line contained DELIMITER_STR (e.g., track a boolean found_delimiter or
inspect the last appended lines for DELIMITER_STR) and if not, raise an
exception or exit with an error message via logging that mentions OPTIONS_RST
and DELIMITER_STR so the failure is explicit; reference the existing
variables/options: OPTIONS_RST, DELIMITER_STR, and lead_in when implementing the
validation and error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Around line 172-176: Add a .PHONY declaration listing the non-file targets so
make won't treat them as files: declare .PHONY for python_doc, python_doc_check
and also include the existing gen and gen_check targets (and any other similar
meta-targets) by adding a .PHONY line that references those target names; update
the Makefile near existing target definitions to include ".PHONY: python_doc
python_doc_check gen gen_check" so these commands are always executed regardless
of filesystem state.

---

Nitpick comments:
In `@python/helper-scripts/make-options-rst.py`:
- Around line 41-45: The loop that reads OPTIONS_RST into lead_in stops only
when DELIMITER_STR is seen, but currently doesn't detect the case where the
delimiter is missing; update the reader logic that iterates over OPTIONS_RST so
after the loop you check whether any line contained DELIMITER_STR (e.g., track a
boolean found_delimiter or inspect the last appended lines for DELIMITER_STR)
and if not, raise an exception or exit with an error message via logging that
mentions OPTIONS_RST and DELIMITER_STR so the failure is explicit; reference the
existing variables/options: OPTIONS_RST, DELIMITER_STR, and lead_in when
implementing the validation and error handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e10115f-d468-4ca6-8f46-e14e89925647

📥 Commits

Reviewing files that changed from the base of the PR and between f455df1 and d8ea921.

📒 Files selected for processing (5)
  • Makefile
  • python/Makefile
  • python/docs/OPTIONS.rst
  • python/helper-scripts/make-options-rst.py
  • python/src/trezorlib/cli/evolu.py
✅ Files skipped from review due to trivial changes (2)
  • python/src/trezorlib/cli/evolu.py
  • python/docs/OPTIONS.rst

Comment thread Makefile
Comment on lines +172 to +176
python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc

python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for .PHONY declarations of gen targets

rg -n '\.PHONY.*\b(gen|gen_check|python_doc|python_doc_check)\b' Makefile

Repository: trezor/trezor-firmware

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Check all .PHONY declarations in the Makefile
rg -n '\.PHONY' Makefile -A 1

Repository: trezor/trezor-firmware

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Check if gen and gen_check targets exist
rg -n '^(gen|gen_check|python_doc|python_doc_check):' Makefile -A 2

Repository: trezor/trezor-firmware

Length of output: 750


🏁 Script executed:

#!/bin/bash
# Check if there are any files named gen, gen_check, python_doc, or python_doc_check
fd -e gen -e gen_check -e python_doc -e python_doc_check . 2>/dev/null | head -20

Repository: trezor/trezor-firmware

Length of output: 48


Add .PHONY declarations for targets.

The Makefile currently has no .PHONY declarations. The new python_doc and python_doc_check targets, as well as the existing gen and gen_check targets, are all non-file-producing targets and should be declared as .PHONY to prevent potential conflicts and follow make best practices.

📝 Proposed PHONY declarations
+.PHONY: python_doc python_doc_check gen gen_check
+
 python_doc: ## generate trezorctl OPTIONS.rst
 	make -C python doc
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc
python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
.PHONY: python_doc python_doc_check gen gen_check
python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc
python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 172 - 176, Add a .PHONY declaration listing the
non-file targets so make won't treat them as files: declare .PHONY for
python_doc, python_doc_check and also include the existing gen and gen_check
targets (and any other similar meta-targets) by adding a .PHONY line that
references those target names; update the Makefile near existing target
definitions to include ".PHONY: python_doc python_doc_check gen gen_check" so
these commands are always executed regardless of filesystem state.

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.

Add check to CI that verifies OPTIONS.rst are up-to-date

2 participants