Skip to content

fix: resolve docs/notebooks symlink so notebook pages render - #745

Merged
joamatab merged 1 commit into
gdsfactory:mainfrom
jackgdsf:fix/nbdocs-resolve-symlink
Aug 1, 2026
Merged

fix: resolve docs/notebooks symlink so notebook pages render#745
joamatab merged 1 commit into
gdsfactory:mainfrom
jackgdsf:fix/nbdocs-resolve-symlink

Conversation

@jackgdsf

@jackgdsf jackgdsf commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #744. The previous fix (find -L) solved notebook discovery but the pages still 404 because zensical/mkdocs also doesn't follow symlinks when scanning docs_dir for source files. The generated .md files exist (build logs show all 32 notebooks converted) but zensical never picks them up.

This PR replaces the symlink with a real directory copy at the start of the nbdocs target:

if [ -L docs/notebooks ]; then
    target=$(readlink -f docs/notebooks)
    rm docs/notebooks
    cp -r "$target" docs/notebooks
fi

This resolves both issues at once — find and zensical both see a real directory.

Fixes #743

Test plan

  • CI docs build passes
  • Deployed site shows notebook pages with proper titles (not "none")
  • Notebook pages load without 404

Reminder: AI-created PRs still require human review of the actual code changes before merge. I'll open the PR, but a human must review and approve it.

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Resolve docs/notebooks symlink before nbdocs conversion so mkdocs/zensical can detect generated notebook markdown files.

The symlink `docs/notebooks -> ../notebooks` breaks both `find`
(can't discover .ipynb files) and zensical/mkdocs (can't discover
generated .md files during site build). Instead of adding `-L` flags
everywhere, resolve the symlink to a real directory copy at the start
of the nbdocs target. This way both nbconvert and zensical see a
real directory and work correctly.

Fixes gdsfactory#743

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai

sourcery-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the nbdocs Makefile target so that notebook markdown files under docs/notebooks are discoverable by the docs build system, by resolving and replacing a symlink with a real directory before running nbconvert over all notebooks.

Flow diagram for updated nbdocs Makefile target

flowchart TD
    A[nbdocs target invoked] --> B{docs/notebooks is symlink?}
    B -- yes --> C[readlink -f docs/notebooks]
    C --> D[rm docs/notebooks]
    D --> E[cp -r target docs/notebooks]
    B -- no --> F[use existing docs/notebooks directory]
    E --> G[find docs -name *.ipynb]
    F --> G[find docs -name *.ipynb]
    G --> H[jupyter nbconvert --to markdown --embed-images]
    H --> I[mkdocs/zensical scans docs_dir and finds generated .md]
Loading

File-Level Changes

Change Details Files
Ensure docs/notebooks symlink is resolved into a real directory before converting notebooks so the docs generator can see the produced .md files.
  • Add a shell pre-step in the nbdocs Makefile target that checks if docs/notebooks is a symlink and, if so, reads its real path, removes the symlink, and copies the target directory into docs/notebooks.
  • Remove use of the -L flag from the find invocation in nbdocs and instead run find directly over docs to locate .ipynb files.
  • Keep existing nbconvert invocation and no-exec pattern filtering logic unchanged, relying on the new directory copy to make generated markdown visible to zensical.
Makefile

Assessment against linked issues

Issue Objective Addressed Explanation
#743 Update the docs build tooling (Makefile nbdocs target) so that all notebook .ipynb files under docs/notebooks are discovered and converted to markdown during the docs build.
#743 Ensure that the generated notebook markdown pages are correctly picked up by the site generator so that notebook entries in the left navigation have proper titles and do not 404.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The use of readlink -f is non-portable and will fail on macOS/BSD; consider a POSIX-compatible alternative or a small helper script to resolve the symlink target more robustly.
  • Dropping -L from the find call changes behavior for any other symlinked notebook locations under docs; if those are expected, you may want to keep -L or otherwise ensure they’re still discovered.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The use of `readlink -f` is non-portable and will fail on macOS/BSD; consider a POSIX-compatible alternative or a small helper script to resolve the symlink target more robustly.
- Dropping `-L` from the `find` call changes behavior for any other symlinked notebook locations under `docs`; if those are expected, you may want to keep `-L` or otherwise ensure they’re still discovered.

## Individual Comments

### Comment 1
<location path="Makefile" line_range="69-70" />
<code_context>
 	@echo "Converting notebooks to markdown..."
-	@find -L docs -name "*.ipynb" | while read nb; do \
+	@# Resolve symlink so zensical can discover the generated .md files
+	@if [ -L docs/notebooks ]; then \
+		target=$$(readlink -f docs/notebooks) && \
+		rm docs/notebooks && \
+		cp -r "$$target" docs/notebooks; \
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `readlink -f` may break on systems where `-f` isn't supported (e.g. macOS).

On macOS and some BSD systems `readlink` doesn’t support `-f`, so this logic will fail and break `nbdocs` on those platforms. If cross-platform support is required, please replace this with a portable approach (e.g. a small `python -c` to resolve the symlink, or a POSIX-compatible `cd`/`pwd` pattern).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread Makefile
@joamatab
joamatab merged commit 60fd733 into gdsfactory:main Aug 1, 2026
16 of 18 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.

Docs site: all notebook pages in left nav are broken

2 participants