DEV Community

kAZUYA tAKEI
kAZUYA tAKEI

Posted on

A short hack to deploy reveal.js presentation on Read the Docs

This is an introduction to serve reveal.js slide to Read the docs.

Abstract

Edit your conf.py to override target builder.

def override_builder(app, config):
    # Change for your RTD settings. Please set it in your RTD prject
    app.registry.builders["singlehtml"] = app.registry.builders["revealjs"]

def setup(app):
    app.connect("config-inited", override_builder)
Enter fullscreen mode Exit fullscreen mode

You can see contents and sources.

Approaching

Problems for regular usage to server sphinx-revealjs

Read the docs are documentation platform supporting Sphinx.
You can serve HTML files from Sphinx documentation as same as run make html on local.

sphinx-revealjs is Sphinx extension to provide builder that generate Reveal.js style HTML. (ex: call make revealjs)

RTD supports only html, dirhtml and singlehtml for HTML buildings.
So, it is difficult to server reveal.js presentation of sphinx-revealjs.

Sphinx can override builder object

Sphinx provides Application API to inject procedures on some events.
config-inited event is called on after loading all configuration before creating target-builder object.

We can modify builder-class in the handler for this event, and can use any builder in RTD.
(please see abstract for example)

Caution

Cannot serve regular name builds

This hack switches the builder, and you cannot use regular builder.
You should be careful what builder you want to call.

RTD widget is not working

RTD provides widget for versioning and i18n.
But reveal.js content does not render wighet.
You can serve single version presentation only!

This hack is NOT clean

This is dirty hack.
RTD may not accept this hack in backend.

Top comments (0)