Skip to content

Is it possible to get read the docs to run a custom python script as part of the build? #2276

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

Closed
TimKam opened this issue Jun 25, 2016 · 7 comments
Labels
Support Support question

Comments

@TimKam
Copy link

TimKam commented Jun 25, 2016

Specifically, I'd like to run a script that:

  • Builds the txt files of my Sphinx project.
  • Processes the these txt files further.
  • Replaces the content in the html/_sources directory with these files.

I have this script in place locally, but don't know if and how I can get it executed by the read the docs sever as part of the build process.

@zxiiro
Copy link
Contributor

zxiiro commented Jul 9, 2016

It's a hack but you can add your scripts to the bottom of conf.py. I have some shell scripts that I run by inserting subprocess.call() into conf.py.

@agjohnson
Copy link
Contributor

Sounds like you want to include your methods as a hook into one of the Sphinx events. Use a setup function in your conf.py to interact with the state around the Sphinx application:

def setup(app):
    ...

@agjohnson agjohnson added the Support Support question label Jul 11, 2016
@TimKam
Copy link
Author

TimKam commented Jul 12, 2016

Thank you very much @zxiiro , @agjohnson .
In case somebody else will have the same question: here is a link to the section in the Sphinx documentation that lists the core events you can tap into.

@willingc
Copy link
Contributor

@TimKam Thanks for the link. Are you ready to close this issue?

@TimKam TimKam closed this as completed Jul 21, 2016
@bradjc
Copy link

bradjc commented Jun 23, 2017

Is this possible when using Mkdocs?

williamcroberts pushed a commit to williamcroberts/tpm2-pytss that referenced this issue Apr 19, 2021
scripts/docs.sh was running sphinx build and then a custom post-process
command. Move this post-process command into a seperate script that is
invoked through the API extensions built into sphinx. This way servers
like ReadTheDocs can get the invocation.

This approach was discussed here:
  - readthedocs/readthedocs.org#2276

Then modified for our purposes.

Signed-off-by: William Roberts <[email protected]>
williamcroberts pushed a commit to williamcroberts/tpm2-pytss that referenced this issue Apr 19, 2021
scripts/docs.sh was running sphinx build and then a custom post-process
command. Move this post-process command into a seperate script that is
invoked through the API extensions built into sphinx. This way servers
like ReadTheDocs can get the invocation.

This approach was discussed here:
  - readthedocs/readthedocs.org#2276

Then modified for our purposes.

Signed-off-by: William Roberts <[email protected]>
williamcroberts pushed a commit to tpm2-software/tpm2-pytss that referenced this issue Apr 19, 2021
scripts/docs.sh was running sphinx build and then a custom post-process
command. Move this post-process command into a seperate script that is
invoked through the API extensions built into sphinx. This way servers
like ReadTheDocs can get the invocation.

This approach was discussed here:
  - readthedocs/readthedocs.org#2276

Then modified for our purposes.

Signed-off-by: William Roberts <[email protected]>
@ghost
Copy link

ghost commented Apr 22, 2021

All of these are really bad solutions...

I have a setup.py apidoc command that does what the name suggests, i.e. it calls the sphinx.ext.apidoc.main to generate RST files, which then should be processed by setup.py build_sphinx.

While .readthedocs.yaml tried to automate few things, it made basic and already existing automation impossible... why?

Configuration is not the place to run scripts. But, a command to generate documentation is. Why do it backwards?

Please make it possible to do it right instead of adding another layer of duct tape around the problem.

@astrojuanlu
Copy link
Contributor

Hi @wvxvw , thanks for your interest on Read the Docs! For apidoc in particular, I think this extension does exactly what you need https://github.com/sphinx-contrib/apidoc without having to add a custom command. Let us know in #8133 if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

6 participants