Making books#
Summary#
System |
Valid input files |
Compatibility with Python & R |
Blog posts (tags, dates, filters) ? |
Nice examples |
Additional details |
---|---|---|---|---|---|
Jupyter Book |
- Markdown |
Python tool. Would probably only use with R if you were working with R in |
Not found example |
Easy integration with BinderHub and Google Colab [source] |
|
Sphinx |
- reStructured Text |
Designed for Python, didn’t easily run into R implementation, but examples here in various languages |
Yes |
pyOpenSci |
Thumbnail gallery, Binder, nbviewer [source] |
Quarto |
- Cross-language Quarto markdown |
Explicitly supports dynamic content from Python, R, Julia and Observable [source] |
Well supported natively |
ddanieltan’s blog |
Huge range of supported output formats [source] |
Jekyll |
- Markdown |
Written in Ruby. Creates simple static sites. |
Exeter RSE Workshop - github, site |
||
Mkdocs |
- Markdown |
Designed for Python |
Yes with Material for Mkdocs plugin |
Material for MkDocs - github, site |
Material for MkDocs provides additional features |
Bookdown |
- R Markdown |
Designed for R |
|||
Blogdown |
- R Markdown |
Designed for R |
|||
Hugodown |
- R Markdown |
Designed for R |
Built on Hugo |
||
Distill for R Markdown |
- R Markdown |
Designed for R |
Yes natively (eg. set up project as blog or website) |
Reflections on RMarkdown, Distill, Bookdown and Blogdown.
Paid: https://www.gitbook.com/pricing
Other random noted down options not explored:
Sandpaper, pegboard and varnish - example: https://carpentries-lab.github.io/good-enough-practices/index.html
Sweave/LaTeX RStudio/LaTeX Pandoc SageMath Colab Notebooks Nbconvert Pelican Org mode DocOnce Scribus Madoko Texinfo
Quarto#
Getting set up…
Install Quarto - https://quarto.org/docs/get-started/ - I downloaded the Linux deb file, then ran
sudo dpkg -i packagename.deb
Create environment with necessary requirements (this may not be a necessary step, but this is what I decided to do) - for me, I needed:
ipykernel
pyyaml
nbformat
nbclient
Install Quarto VS Code extension (and then perhaps open and close VS Code)
Within VS Code, Ctrl+Shift+P > Quarto: Create Project
Ctrl+Shift+P > Select Interpreter > choose the environment created
Render full .qmd: Ctrl+Shift+K
Render file: quarto render hello.qmd --to html
Render to alt. output: quarto render hello.qmd --to docx
Run individual cells by selecting the Run Cell button.
You’ll see there’s a few Quarto projects that pop up -
Basic
Book
Blog
Manuscript
Website
A book is actually a special type of website - the most important difference is that it uses chapter numbers and supports cross-references between different chapters. [source]
For a blog, the posts are in seperate pages as the filename has to be index.qmd.
To change preview type when using VSCode to preview, go to Settings > Quarto > Render: Preview Type and set to external
Commands to check/make/preview book:
quarto check
- checks if would build successfullyquarto preview
- previews as-isquarto render
- rebuilds whole bookquarto preview button in VS code - will render current page, and will render other pages when you click on them, except blog posts
Jupyter book#
Install jupyter-book package.
To create sample book stored in current location: jupyter-book create book_name/
To build/rebuild book: jupyter-book build book_name
If add new page and book table of contents doesn’t update upon rebuild, try: jupyter-book build --all book_name
Sphinx#
Note: Written for package documentation
To convert from Jupyter book to sphinx, run: jupyter-book config sphinx path/to/book
. This will generate a conf.py file from your _config.yml and _toc.yml files. You can then run `sphinx-build path/to/book path/to/book/_build/html -b html.
Add to environment:
sphinx
sphinx-rtd-theme
myst-parser
sphinx-autoapi
Create directory called
docs
and enter it - e.g.mkdir docs
andcd docs
.Add/create any files you want to include in the docs (e.g. how to guides, descriptions) - can be markdown or rst - e.g. guide1.md and guide2.md
Run
sphinx-quickstart
Modify index.rst file - this is used as home page - e.g.
Documentation for package name
==============================
This package...
.. note::
This project is under active development.
If you don’t want toctree within the home page, and just want it to be in the sidebar, then produce a
contents.rst
- e.g.
Site contents
*************
.. toctree::
Home <index>
guide1
guide2
Modify conf.py - e.g.
# -- General configuration ---------------------------------------------------
extensions = [
'myst_parser', # To use markdown as well as reStructuredText
'autoapi.extension' # Auto generate module and function documentation
]
# Location of files for auto API
autoapi_dirs = ['../kailo_beewell_dashboard']
# File types for documentation
source_suffix = ['.rst', '.md']
templates_path = ['_templates']
# Location of toctree
master_doc = 'contents'
exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store']
language = 'English'
# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
Produce the documentation. Any time you want to do this, from the docs folder, run:
make clean
(to clear out build folder, else might not update everything fully)make html