Skip to content

Commit

Permalink
docs: add sphinx to project to build documentation static site
Browse files Browse the repository at this point in the history
add sphinx to main conda environment
add rules to makefile to build and launch a test server
add sphinx config files
add sphinx version to pyproject.toml (commitizen)
  • Loading branch information
Michele-Alberti committed Nov 3, 2024
1 parent 2a5102d commit b033947
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,5 @@ dist

/shared_data/
/ssl/
*.csv
*.csv
/docs/api/
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/_static/favicon.ico
Binary file not shown.
Binary file added docs/_static/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added docs/_templates/.gitkeep
Empty file.
124 changes: 124 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys

sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "Data-Lunch"
copyright = "2024, Michele Alberti"
author = "Michele Alberti"
release = "v3.3.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx.ext.graphviz",
# "sphinxext.rediraffe",
# "sphinx_design",
# "sphinx_copybutton",
"autoapi.extension",
# For extension examples and demos
"myst_parser",
# "ablog",
# "jupyter_sphinx",
# "nbsphinx",
# "numpydoc",
# "sphinx_togglebutton",
# "jupyterlite_sphinx",
"sphinx_favicon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]

intersphinx_mapping = {
"sphinx": ("https://www.sphinx-doc.org/en/master", None)
}

# -- MyST options ------------------------------------------------------------

# This allows us to use ::: to denote directives, useful for admonitions
myst_enable_extensions = ["colon_fence", "linkify", "substitution"]
myst_heading_anchors = 2
# myst_substitutions = {"rtd": "[Read the Docs](https://readthedocs.org/)"}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "pydata_sphinx_theme"
# html_logo = "_static/logo.png"
html_favicon = "_static/favicon.ico"

html_theme_options = {
"logo": {
"text": "Data-Lunch Documentation",
"image_light": "_static/logo-light.png",
"image_dark": "_static/logo-dark.png",
},
"header_links_before_dropdown": 4,
"show_toc_level": 2,
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
# "show_nav_level": 2,
"footer_start": ["copyright"],
"footer_center": ["sphinx-version"],
# "back_to_top_button": False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# html_css_files = ["custom.css"]
# html_js_files = ["pydata-icon.js", "custom-icon.js"]
# todo_include_todos = True

# -- favicon options ---------------------------------------------------------

# see https://sphinx-favicon.readthedocs.io for more information about the
# sphinx-favicon extension
favicons = [
# generic icons compatible with most browsers
# "favicon-32x32.png",
# "favicon-16x16.png",
{"rel": "shortcut icon", "sizes": "any", "href": "favicon.ico"},
# chrome specific
# "android-chrome-192x192.png",
# apple icons
# {"rel": "mask-icon", "color": "#459db9", "href": "favicon.ico"},
# {"rel": "apple-touch-icon", "href": "favicon.ico"},
# msapplications
# {"name": "msapplication-TileColor", "content": "#459db9"},
# {"name": "theme-color", "content": "#ffffff"},
# {"name": "msapplication-TileImage", "content": "mstile-150x150.png"},
]

# -- Options for autosummary/autodoc output ------------------------------------
autosummary_generate = True
autodoc_typehints = "description"
autodoc_member_order = "groupwise"

# -- Options for autoapi -------------------------------------------------------
autoapi_type = "python"
autoapi_dirs = ["../dlunch"]
autoapi_keep_files = True
autoapi_root = "api"
autoapi_member_order = "groupwise"
6 changes: 6 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Read-Me
=======

.. include:: ../README.md
:parser: myst_parser.sphinx_
:start-after: google-cloud-platform-utilities)
13 changes: 13 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. Data-Lunch documentation master file, created on Sat Nov 2 15:14:49 2024.
Data-Lunch
==========

The ultimate web app for a well organized lunch.

.. toctree::
:maxdepth: 3
:hidden:

getting_started
api/index
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
18 changes: 18 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@ clean-docker:
docker system prune -f
@echo -e "${GREEN}done${NC}"

# Docs rules ------------------------------------------------------------------
#sphinx-apidoc:
# @echo -e "${YELLOW}auto build rst files from docstrings${NC}"
# @sphinx-apidoc --module-first --separate --remove-old -o docs/_modules dlunch
# @echo -e "${GREEN}done${NC}"

sphinx-build:
@echo -e "${YELLOW}build html docs pages${NC}"
@cd docs && make html
@echo -e "${GREEN}done${NC}"

docs: sphinx-build
@echo -e "${GREEN}docs build successfully${NC}"

docs-serve: docs
@cd docs/_build/html && python -m http.server -b 127.0.0.1 8000


# Other rules -----------------------------------------------------------------

interrogate:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ version = "3.3.0"
version_files = [
"dlunch/__init__.py",
"pyproject.toml:version",
"docs/conf.py:release",
]
tag_format = "v$version"
changelog_file = "changelog.md"
Expand Down
5 changes: 5 additions & 0 deletions requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ dependencies:
- hydra-core=1.3.2
- google-cloud-storage=2.17.0
- pytesseract=0.3.10
- sphinx=8.1.3
- pydata-sphinx-theme=0.16.0
- myst-parser=4.0.0
- sphinx-autoapi=3.3.3
- sphinx-favicon=1.0.1

0 comments on commit b033947

Please sign in to comment.