sphinx-autobuild icon indicating copy to clipboard operation
sphinx-autobuild copied to clipboard

Allow for generic build command (for use with jupyter-book)

Open amichuda opened this issue 5 years ago • 4 comments
trafficstars

I wanted to see if it was possible to use sphinx-autobuild with building with jupyter-book. As of now it seems that this is possible as the get_builder function runs sphinx explicitly. Would it be possible to have the server watch a sourcedir and outdir but for a generic command (such as jb build)?

amichuda avatar Nov 05 '20 08:11 amichuda

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Nov 05 '20 08:11 welcome[bot]

You can add --pre-build "jb build" today, to run that build and pass additional --watch options as well.

As it stands, this is a really thin wrapper over livereload (the Python package). It might make sense for jupyter-book to get a serve command that uses that directly. FWIW, it's even pretty straightforward to write a script that does the right thing, using only livereload.

import subprocess
import livereload

def run():
    subprocess.run(["jupyter-book", "build"])

server = livereload.Server()
server.watch('docs/source', run)

server.serve(root='docs/build/html')

pradyunsg avatar Nov 05 '20 11:11 pradyunsg

I want to use sphinx-autorebuild with sphinx-multiversion, which itself wraps the sphinx-build command to build versioned documentation. Would it be possible to parameterize the currently hard-coded sphinx-build invocation via a command line option (e.g., --build-cmd)?

ashwin153 avatar Jun 15 '21 00:06 ashwin153

Heya, as I note in https://github.com/executablebooks/jupyter-book/issues/1455:

jupyter-book now has the ability for external packages to "inject" commands in to its CLI, this is for example how jupyter-book toc works (executablebooks/sphinx-external-toc@ec4a439/setup.cfg#L43-L44). By the same mechanism, sphinx-autobuild could inject a jupyter-book serve command, that is customized for jupyter-book

chrisjsewell avatar Sep 13 '21 23:09 chrisjsewell