aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Yoshimi <byoshimi@google.com>2022-08-22 15:16:23 -0700
committerCopybara-Service <copybara-worker@google.com>2022-08-22 15:16:56 -0700
commit9078fc40dc7809173e51ce8fca600033d17c493a (patch)
tree1181112a13aaaffe74c936439b52cf4842552717
parent2e3d4b4de7e576bba59d247a956c6e5fe3c0c5bb (diff)
downloadabsl-py-9078fc40dc7809173e51ce8fca600033d17c493a.tar.gz
Add support for readthedocs.io.
PiperOrigin-RevId: 469296283 Change-Id: Ia5c54c633586b90ab57aa81b5813878fa49997dd
-rw-r--r--.readthedocs.yaml21
-rw-r--r--docs/Makefile37
-rw-r--r--docs/source/conf.py60
-rw-r--r--docs/source/index.rst16
-rw-r--r--docs/source/readme_link.rst1
5 files changed, 135 insertions, 0 deletions
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000..e7b7d9b
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,21 @@
+# .readthedocs.yaml
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+# Set the version of Python and other tools you might need
+python:
+ version: "3"
+ install:
+ - method: pip
+ path: .
+ extra_requirements:
+ - m2r2
+ - sphinxcontrib-apidoc
+
+# Build documentation in the docs/ directory with Sphinx
+sphinx:
+ builder: html
+ configuration: docs/source/conf.py
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..8f39a96
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,37 @@
+# Minimal makefile for Sphinx documentation
+#
+# To generate html docs locally:
+# Recommend doing this from a virtual environment:
+# $ sudo apt-get install virtualenv python3-venv
+# $ virtualenv myproject # or python3 -m venv myproject
+# $ source myproject/bin/activate
+#
+# Then install sphinx packages (if running locally)
+# $ pip install m2r2
+# $ pip install sphinxcontrib-apidoc
+# $ pip install sphinx-rtd-theme
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SOURCEDIR = ../absl
+RSTDIR = source
+HTMLDIR = build
+HTMLDIR = build
+# If you change the conf.py apidoc_excluded_paths, you need to update
+# the excluded paths in APIDOC_EXCLUDE too. The paths are relative
+# to the docs/ directory (if you want to filter out absl/tests you need
+# to use "../*/tests".)
+APIDOC_EXCLUDE = ../*/*/tests/* ../*/tests/*
+SPHINXBUILD ?= sphinx-build
+SPHINXAPIDOC ?= sphinx-apidoc
+
+# Build .rst files for all Python sources in SOURCEDIR.
+# This rule isn't called by readthedocs, its only used for manual testing.
+rstfiles:
+ @$(SPHINXAPIDOC) -o $(RSTDIR) $(SOURCEDIR) $(APIDOC_EXCLUDE)
+
+# Run after "make rstfiles"
+# You can review sphinx generated files in docs/build directory.
+htmlfiles:
+ @$(SPHINXBUILD) -b html -c $(RSTDIR) $(RSTDIR) $(HTMLDIR)
diff --git a/docs/source/conf.py b/docs/source/conf.py
new file mode 100644
index 0000000..364c154
--- /dev/null
+++ b/docs/source/conf.py
@@ -0,0 +1,60 @@
+"""Sphinx config file for https://github.com/abseil/abseil-py."""
+
+import os
+import sys
+
+# -- Project information
+project = 'Abseil Python Common Libraries'
+copyright = '2022, Abseil' # pylint: disable=redefined-builtin
+author = 'The Abseil Authors'
+
+release = ''
+version = ''
+
+# -- General configuration
+
+extensions = [
+ 'sphinx.ext.duration',
+ 'sphinx.ext.doctest',
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.autosummary',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.napoleon',
+ 'sphinx.ext.viewcode',
+ 'sphinx.ext.coverage',
+ 'sphinxcontrib.apidoc', # convert .py sources to .rst docs.
+ 'm2r2', # for .md files
+]
+
+# sphinxcontrib.apidoc vars
+apidoc_module_dir = '../../absl'
+apidoc_output_dir = '.'
+apidoc_toc_file = False
+apidoc_excluded_paths = [
+ '*/tests/*',
+ 'tests/*',
+]
+apidoc_separate_modules = True
+
+intersphinx_mapping = {
+ 'python': ('https://docs.python.org/3/', None),
+ 'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
+}
+intersphinx_disabled_domains = ['std']
+
+source_suffix = {
+ '.rst': 'restructuredtext',
+ '.md': 'markdown',
+}
+
+templates_path = ['_templates']
+
+# -- Options for HTML output
+
+html_theme = 'sphinx_rtd_theme'
+
+# -- Options for EPUB output
+epub_show_urls = 'footnote'
+
+sys.path.insert(0, os.path.abspath('../..')) # access to README.md
+sys.path.insert(0, os.path.abspath('../../absl')) # access to python sources
diff --git a/docs/source/index.rst b/docs/source/index.rst
new file mode 100644
index 0000000..4bd00f9
--- /dev/null
+++ b/docs/source/index.rst
@@ -0,0 +1,16 @@
+.. include:: readme_link.rst
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+ :glob:
+
+ *
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/source/readme_link.rst b/docs/source/readme_link.rst
new file mode 100644
index 0000000..3bd447c
--- /dev/null
+++ b/docs/source/readme_link.rst
@@ -0,0 +1 @@
+.. mdinclude:: ../../README.md