Skip to content

docs sidebar have long names - #385

Open
elyes298 wants to merge 57 commits into
ymahlau:mainfrom
elyes298:main
Open

docs sidebar have long names#385
elyes298 wants to merge 57 commits into
ymahlau:mainfrom
elyes298:main

Conversation

@elyes298

@elyes298 elyes298 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

addresses issue #151 which is now solved

Summary by CodeRabbit

  • Documentation
    • Improved Sphinx sidebar navigation by hiding parent entries in the TOC.
    • Updated API signature rendering to remove module-name prefixes while preserving default parameter values.
    • Added a defensive adjustment in the MathJax setup to help prevent documentation build failures.
  • Chores
    • Enabled and configured automated docstring linting in the pre-commit workflow.
    • Introduced project-wide pydoclint rules to standardize docstring style and relax specific validation checks.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7493805e-6b82-42bb-8058-2938a8f6c274

📥 Commits

Reviewing files that changed from the base of the PR and between 541e842 and 7935121.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

Sphinx documentation settings were updated, the original object description function is saved, and project-specific pydoclint configuration was added.

Changes

Documentation and docstring tooling

Layer / File(s) Summary
Sphinx configuration updates
docs/source/conf.py
Adjusts TOC and autodoc settings, preserves HTML configuration spacing, and stores the original object_description function.
Docstring linting configuration
pyproject.toml, .pre-commit-config.yaml
Adds pydoclint settings and applies a whitespace-only change to the existing ty hook configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit tunes the docs with care,
While linting hops through settings there,
Sphinx keeps its pages bright,
Defaults stay tucked just right,
And tidy hooks wait in their lair. 🐇📚

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the docs sidebar cleanup theme, though it’s phrased awkwardly and omits the Sphinx config details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@docs/source/_static/custom.js`:
- Around line 10-13: The text-shortening logic in custom.js is too broad because
it rewrites any dotted literal, which can incorrectly alter TOC entries like
config.yaml or version strings. Update the handling around the
text.includes(".") branch to only truncate API-style identifiers, using a
stricter guard in the same DOM/TOC processing path so ordinary dotted names and
config keys are left unchanged.
🪄 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: 4353124e-271d-426b-b412-14958409d1f9

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab6fe2 and 34c1c2b.

📒 Files selected for processing (4)
  • docs/source/_static/custom.js
  • docs/source/conf.py
  • src/fdtdx/conversion/vti.py
  • src/fdtdx/core/jax/pytrees.py

Comment thread docs/source/_static/custom.js Outdated
Comment on lines +10 to +13
// If the text contains a dot (e.g., "ExtrudedPolygon.axis"), keep only the last part ("axis")
if (text.includes(".")) {
const parts = text.split(".");
textTarget.textContent = parts[parts.length - 1];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Narrow the truncation to API identifiers.

This currently rewrites every dotted code literal in the page TOC, so entries like config.yaml, Python 3.12, or dotted config keys can be shortened incorrectly once custom.js is loaded globally.

Proposed guard
-        // If the text contains a dot (e.g., "ExtrudedPolygon.axis"), keep only the last part ("axis")
-        if (text.includes(".")) {
+        // If the text is a dotted Python identifier (e.g., "ExtrudedPolygon.axis"), keep only the last part ("axis")
+        const isDottedIdentifier = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)+$/.test(text.trim());
+        if (isDottedIdentifier) {
             const parts = text.split(".");
+            node.title = text;
             textTarget.textContent = parts[parts.length - 1];
         }
📝 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
// If the text contains a dot (e.g., "ExtrudedPolygon.axis"), keep only the last part ("axis")
if (text.includes(".")) {
const parts = text.split(".");
textTarget.textContent = parts[parts.length - 1];
// If the text is a dotted Python identifier (e.g., "ExtrudedPolygon.axis"), keep only the last part ("axis")
const isDottedIdentifier = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)+$/.test(text.trim());
if (isDottedIdentifier) {
const parts = text.split(".");
node.title = text;
textTarget.textContent = parts[parts.length - 1];
🤖 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 `@docs/source/_static/custom.js` around lines 10 - 13, The text-shortening
logic in custom.js is too broad because it rewrites any dotted literal, which
can incorrectly alter TOC entries like config.yaml or version strings. Update
the handling around the text.includes(".") branch to only truncate API-style
identifiers, using a stricter guard in the same DOM/TOC processing path so
ordinary dotted names and config keys are left unchanged.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (37f4039) to head (7935121).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
+ Coverage   90.35%   90.52%   +0.17%     
==========================================
  Files          92       92              
  Lines       11789    11920     +131     
  Branches     1803     1820      +17     
==========================================
+ Hits        10652    10791     +139     
+ Misses        794      783      -11     
- Partials      343      346       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ymahlau ymahlau changed the title issue 151 docs sidebar have long names Jul 2, 2026
@ymahlau

ymahlau commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Hi @elyes298, please do not write custom JS for this task. It is almost certainly unnecessary and definitely not maintainable

Comment thread src/fdtdx/conversion/vti.py Outdated
if not all(str(a.dtype) in NUMPY_TO_VTK_DTYPE for a in cell_data.values()):
raise ValueError(f"VTK export only supports dtypes {list(NUMPY_TO_VTK_DTYPE.keys())}.")
return shape
return shape[0], shape[1], shape[2]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why a change here? please revert

Comment thread src/fdtdx/core/jax/pytrees.py Outdated
current_parent = None
else:
current_parent = getattr(current_parent, op)
current_parent = getattr(current_parent, str(op))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same here

Comment thread docs/source/conf.py Outdated
exclude_patterns = []

# Hides the class/module nae in the right sidebar
toc_object_entries_show_parent = 'hide'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should be toc_object_entries_show_parents = 'hide' (you are missing a plural s). Does it work by just setting that option?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/source/conf.py (1)

104-117: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make the fallback observable

autodoc_preserve_defaults only changes how defaults are rendered, so it doesn’t replace this shim; sphinx.util.inspect.object_description is still the hook on the pinned Sphinx line. Keep the fallback only if it still covers a real failure path, but log the exception instead of silently degrading to a generic <ClassName object> / <object>.

🤖 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 `@docs/source/conf.py` around lines 104 - 117, The fallback in
_safe_object_description is currently silent, so keep the shim only if it still
handles a real failure path but make the exception observable when
sphinx.util.inspect.object_description fails. Update the
_safe_object_description wrapper in docs/source/conf.py to log or report the
caught exception before returning the generic fallback string, while preserving
the existing _original_object_description behavior and the
sphinx.util.inspect.object_description override.
🤖 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.

Nitpick comments:
In `@docs/source/conf.py`:
- Around line 104-117: The fallback in _safe_object_description is currently
silent, so keep the shim only if it still handles a real failure path but make
the exception observable when sphinx.util.inspect.object_description fails.
Update the _safe_object_description wrapper in docs/source/conf.py to log or
report the caught exception before returning the generic fallback string, while
preserving the existing _original_object_description behavior and the
sphinx.util.inspect.object_description override.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c76dc4bb-2cce-44b7-94db-27a9957d4de4

📥 Commits

Reviewing files that changed from the base of the PR and between 34c1c2b and 6197687.

📒 Files selected for processing (1)
  • docs/source/conf.py

Comment thread docs/source/conf.py

import sphinx.util.inspect

_original_object_description = sphinx.util.inspect.object_description

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@elyes298 please remove the old stale part

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.

2 participants