Commit 44354b0
authored
Fix image handling for RTD builds (#260)
* Fix image handling for RTD builds
- Implement automatic image collection from multiple source locations
- Add path fixing for included markdown files (source and doctree level)
- Use builder-inited event for reliable image copying timing
- Add build output copying to ensure images are available in HTML
- Fix HTML paths to use relative paths for local file viewing
- Remove debug code and update README with image handling instructions
This fix ensures images work correctly on both branch and main RTD builds,
as well as local builds. The solution is generic and works for any
contributor adding images anywhere in the documentation.
Tested and verified on both test branch and main branch RTD builds.
* fix: remove unused os imports in image handling functions
Addresses review comment: 'Unused import.'
Removed unused 'import os' statements from:
- fix_included_image_paths_source()
- fix_included_image_paths_doctree()
- copy_images_to_build_output()
* fix: use specific exceptions instead of generic Exception catch
Addresses review comments:
- 'Should handle specific errors here. Examples: PermissionError, FileNotFoundError'
- 'Isn't this the same as shutil.SameFileError?'
Changed exception handling in image copy operations:
- Use shutil.SameFileError for same-file scenarios (silently skip)
- Catch PermissionError and FileNotFoundError specifically
- Removed string matching on error messages
* fix: prefix unused Sphinx event parameters with underscore
Addresses review comment: 'I think app and docname are not used within
this scope. Please check.'
In fix_included_image_paths_source(), the 'app' and 'docname' parameters
are required by Sphinx's source-read event signature but not used in the
function body. Prefixed with underscore to indicate intentional non-use.
Added docstring Args section to document this design decision.
* feat: add support for image titles in markdown image syntax
Addresses review comment: Support images with titles like .
Updated the regex pattern to handle both:
- Basic images: 
- Images with titles: 
The regex now:
- Extracts the path separately from the optional title
- Preserves the title in the fixed output path
- Handles all existing path patterns correctly
Tested with various scenarios including paths with spaces and titles.1 parent a77b616 commit 44354b0
2 files changed
+343
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
0 commit comments