Opened 3 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#37157 closed Cleanup/optimization (fixed)

Document how sphinx-autobuild can be used for nicer, faster, and better doc writing process

Reported by: Mike Edmunds Owned by: SnippyCodes
Component: Documentation Version: 6.0
Severity: Normal Keywords: sphinx
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CPython's docs Makefile includes an htmllive target that's extremely helpful while working on docs. It:

  • Builds the docs
  • Opens a web browser on the local docs build (like Django's "make htmlview")
  • Watches the docs source and rebuilds after any changes
  • Hot reloads updated pages

All of this is via sphinx-autobuild.

We should borrow that "htmllive" target for Django's docs/Makefile.

(I haven't investigated whether sphinx-autobuild works on Windows. If so, we'd also add it in docs/make.bat.)

Change History (12)

comment:1 by Mike Edmunds, 3 weeks ago

Owner: set to Mike Edmunds
Status: newassigned

comment:2 by Mike Edmunds, 3 weeks ago

Owner: Mike Edmunds removed
Status: assignednew

Note that sphinx-autobuild can be used with the existing docs/Makefile by setting a few variables:

python -m pip install sphinx-autobuild
cd docs
SPHINXBUILD=sphinx-autobuild SPHINXOPTS=--open-browser make dirhtml

You can substitute make html or any other html-like target. Set SPHINXOPTS='--open-browser --delay 0' if you want the browser to open faster.

Something similar should work on Windows with docs/make.bat, which supports the same variables. (Command syntax is left as an exercise for the reader.)

Although "htmllive" and "dirhtmllive" Makefile targets would be nice, that does add a docs dependency on sphinx-autobuild. (Or starts us down the path of installing dependencies on demand, which is what CPython's Makefile does.) We might prefer to just mention using sphinx-autobuild as a tip in the contributor docs.

comment:3 by Natalia Bidart, 3 weeks ago

Thank you Mike. I've been using forever SPHINXOPTS="--port 5555" SPHINXBUILD=sphinx-autobuild make html (just because I want my docs in the 5555 port). In all honesty, I'm not sure we should add this one to the Makefile. It requires a new dependency and we are very careful about declaring new dependencies in the project.

I wouldn't object to documenting this nicety, though, in the "writing docs" section. I could accept on that premise, otherwise this is a (friendly) wontfix from my POV.

comment:4 by Mike Edmunds, 3 weeks ago

Yeah, I think this would be better as a tip in the docs.

(Can't believe I've been maintaining docs in Sphinx for ~15 years and am just now learning of sphinx-autobuild 🤯)

comment:5 by Natalia Bidart, 3 weeks ago

Triage Stage: UnreviewedAccepted

Great, accepting as a docs addition.

comment:6 by Natalia Bidart, 3 weeks ago

Summary: Add "htmllive" for docs development (sphinx-autobuild)Document how sphinx-autobuild can be used for nicer, faster, and better doc writing process

comment:7 by SnippyCodes, 3 weeks ago

Has patch: set
Owner: set to SnippyCodes
Status: newassigned

comment:8 by Natalia Bidart, 3 weeks ago

Patch needs improvement: set

comment:9 by SnippyCodes, 2 weeks ago

Patch needs improvement: unset

comment:10 by Natalia Bidart, 2 weeks ago

Triage Stage: AcceptedReady for checkin

comment:11 by nessita <124304+nessita@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In 9676439:

Fixed #37157 -- Doc'd usage of sphinx-autobuild for documentation auto-reloading.

comment:12 by Natalia <124304+nessita@…>, 2 weeks ago

In 5a2a523:

[6.1.x] Fixed #37157 -- Doc'd usage of sphinx-autobuild for documentation auto-reloading.

Backport of 967643959f0a6f5351e4fdeb48cf935d787e4e6a from main.

Note: See TracTickets for help on using tickets.
Back to Top