Skip to content

[maint, bugfix] Ensure stub targets generated by prep_stubs generate targets #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean clean-gallery
.PHONY: clean clean-gallery clean-prep clean-full

SPHINXOPTS =

Expand All @@ -18,10 +18,17 @@ clean:
rm -rf $(docs_dir)/_build/
rm -rf $(docs_dir)/api/napari*.rst

clean-prep: clean
rm -rf $(docs_dir)/guides/preferences.md
rm -rf $(docs_dir)/developers/architecture/ui_sections/*ui.md
rm -rf $(doc_dir)/plugins/_npe2*.md

clean-gallery:
rm -rf $(docs_dir)/gallery/*
rm -rf $(docs_dir)/_tags

clean-full: clean-prep clean-gallery

prep-docs:
python $(docs_dir)/_scripts/prep_docs.py

Expand Down
23 changes: 12 additions & 11 deletions docs/_scripts/prep_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ def prep_npe2():

def main(stubs=False):
if stubs:
#prep_npe2()
# Generate stub files for plugin docs
plugin_docs = [
"plugins/_npe2_sample_data_guide.md",
"plugins/_npe2_readers_guide.md",
"plugins/_npe2_widgets_guide.md",
"plugins/_npe2_manifest.md",
"plugins/_npe2_writers_guide.md",
"plugins/_npe2_contributions.md",
]
for doc in plugin_docs:
plugin_docs = {
"plugins/_npe2_sample_data_guide.md": "(sample-data-contribution-guide)=\n",
"plugins/_npe2_readers_guide.md": "(readers-contribution-guide)=\n",
"plugins/_npe2_widgets_guide.md": "(widgets-contribution-guide)=\n",
"plugins/_npe2_manifest.md": "# Manifest Reference\n",
"plugins/_npe2_writers_guide.md": "(writers-contribution-guide)=\n",
"plugins/_npe2_contributions.md": "# Contributions Reference\n(contributions-themes)=\n(contributions-commands)=\n(contributions-widgets)=\n(contributions-readers)=\n(contributions-writers)=\n(contributions-sample-data)=\n(layer-type-constraints)=\n",
}
for doc, target in plugin_docs.items():
file_path = DOCS / doc
if not file_path.exists(): # Avoid overwriting existing files
if file_path.exists(): # Avoid overwriting existing files
Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops! this should have been switched back before going live!

file_path.write_text(
"This is a stub. The real file is autogenerated in a full build.",
f"{target}This is a stub. The real file is autogenerated in a full build.",
encoding="utf-8",
)
# Generate stub files from the other scripts
Expand Down
2 changes: 1 addition & 1 deletion docs/_scripts/update_preference_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def main(stubs=False):
file_path = GUIDES_PATH / "preferences.md"
if not file_path.exists(): # Avoid overwriting existing files
file_path.write_text(
"This is a stub. The real file is autogenerated in a full build.",
"(napari-preferences)=\n# Preferences\nThis is a stub. The real file is autogenerated in a full build.",
encoding="utf-8",
)
else:
Expand Down
2 changes: 1 addition & 1 deletion docs/_scripts/update_ui_sections_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def main(stubs=False):
if not output_page.exists(): # Avoid overwriting existing files
output_page.parent.mkdir(exist_ok=True, parents=True)
output_page.write_text(
"This is a stub. The real file is autogenerated in a full build.",
f"## {section_name}\nThis is a stub. The real file is autogenerated in a full build.",
encoding="utf-8",
)
else:
Expand Down