Skip to content
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

Open
shimizukawa opened this issue Jan 3, 2015 · 6 comments
Open

Support Dynamic Document Injection #1139

shimizukawa opened this issue Jan 3, 2015 · 6 comments
Labels
type:enhancement enhance or introduce a new feature

Comments

@shimizukawa
Copy link
Member

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.


@shimizukawa shimizukawa added the type:enhancement enhance or introduce a new feature label Jan 3, 2015
@webknjaz
Copy link
Contributor

I was wondering about the same problem and tried to return a non-existent document name from the callback for env-get-outdated in hope that I'd catch it later via source-read and return some generated content. But it seems to be silently ignored and is not on the docnames list even in the next event that's happening (env-before-read-docs).
I guess Sphinx excludes invalid doc names right after that event. I'm curious if it could be preserved...

@tk0miya
Copy link
Member

tk0miya commented Oct 27, 2021

Sphinx expects that the filenames that extension returns via env-get-outdated event exist in the file system. At present, there is no way to pass the non-existent documents from extensions.

@webknjaz
Copy link
Contributor

Could you point out where this check happens, please? I'd like to check how hard would it be to improve it.

@tk0miya
Copy link
Member

tk0miya commented Oct 30, 2021

Here:

for docs in self.events.emit('env-get-outdated', self.env, added, changed, removed):
changed.update(set(docs) & self.env.found_docs)

The filenames given from event handlers are compared with found_docs to filter non-existent documents.

@webknjaz
Copy link
Contributor

@tk0miya thanks! Would it be out of line to mutate what found_docs returns from an event handler?

@tk0miya
Copy link
Member

tk0miya commented Oct 31, 2021

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.

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

4 participants