-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support Dynamic Document Injection #1139
Comments
I was wondering about the same problem and tried to return a non-existent document name from the callback for |
Sphinx expects that the filenames that extension returns via |
Could you point out where this check happens, please? I'd like to check how hard would it be to improve it. |
Here: sphinx/sphinx/builders/__init__.py Lines 378 to 379 in 4c91c03
The filenames given from event handlers are compared with |
@tk0miya thanks! Would it be out of line to mutate what |
I'm not sure what will be happened if this line accepts non-existent files. I guess many Sphinx components expect the file must exist. So we have to check whole of Sphinx. |
Partial Duplicate of GH-6829 Documents can be added ('injected') at the A |
@AA-Turner last time I tried that Sphinx was auto-removing those from |
There's no support for entirely in-memory sources at the moment -- I had interpreted this feature request as mainly the dynamic generation aspect. I'd suggest writing to disk and then adding a second callback (either via Feel free to open a new feature request for in-memory sources if it would be useful, though it would probably be a big project. A |
@AA-Turner the OP described what you propose as working. apidoc essentially does that (short of cleanup). So I think that the only correct way to interpret it is supporting in-memory generated documents... |
Another live example of document generation is the PEPs repo, where all of the indices (including PEP 0) are written to disk during the build process. @webknjaz would you be happy opening a new issue? I think it is slightly different, as in-memory sources don't have filenames, last-modified times, etc, so it may be more work to implement -- whereas generating documents and writing them to disk has worked for a while. We could look to add a recipe for this to the docs as a stop-gap? A As an aside, you're listed as an owner of the @reStructuredText organisation on GH -- please could I also be made an owner? I'd like (eventually) to move the rST spec there... (though off topic now!) |
If you're talking as writing to disk, that's probably well-known already. As for in-memory files difficulties, I don't imagine Sphinx itself handling that, just not blocking the addition. I was thinking that a Sphinx extension injecting such documents would handle both generating the content and the cache invalidation. One improvement here could be having a hook point in Sphinx that would allow returning custom cache key values.. If you think it's separate, I'll try to find time to document it later. P.S. I improved your org privileges as asked. |
(re-opening to avoid this getting auto-locked in a week) |
Sphinx is a great tool. However, the need to create rst documents on disk prior to running sphinx-build is a bit inflexible. Sphinx-apidoc works around this limitation by requiring a separate script execution to manage api rst files. While this works, it requires extra steps and maintenance of the on-disk rst files, and additional tools like sphinx-apidoc for each set of dynamic documents generated.
I propose an enhancement to support dynamic document/doctree or perhaps even raw rst injection during sphinx-build execution. Ideally, this would be a hook or similar mechanism that extensions could use to inject documents prior to builder processing.
The text was updated successfully, but these errors were encountered: