Skip to content

Commit

Permalink
Start doc (#66)
Browse files Browse the repository at this point in the history
* sphinx-quickstart

* update .gitignore

* add structure

* iterate on docs

* iterate on docs

* generate CLI reference

* use rtd theme

* syntax

* add hatch dependency
  • Loading branch information
rprimet authored Sep 8, 2023
1 parent a1f2262 commit 7dc48b2
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ __pycache__/
.coverage

.tox/

# Build
dist/
docs/_build/

# CLI reference is auto-generated
docs/cli_reference.md
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)
50 changes: 50 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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

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

from subprocess import PIPE, Popen, run


project = "catleg"
copyright = "2023, the catala contributors"
author = "the catala contributors"

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

extensions = ["myst_parser"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


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

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

# version
pipe = Popen("hatch version", stdout=PIPE, shell=True)
version = pipe.stdout.read().decode("utf8")

# generate CLI reference
# (this command implies that `make html` is executed from the `docs`
# directory -- this could be made more robust?)
run(
[
"typer",
"../src/catleg/catleg.py",
"utils",
"docs",
"--name",
"catleg",
"--output",
"cli_reference.md",
],
check=True,
)
29 changes: 29 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=================
catleg |version|
=================

*A library of helper tools for catala programming in the context of French legislative texts.*

|PyPI| |CI| |License|

.. |PyPI| image:: https://img.shields.io/pypi/v/catleg.svg
:target: https://pypi.org/project/catleg/
.. |CI| image:: https://github.com/CatalaLang/catleg/workflows/check/badge.svg
:target: https://github.com/CatalaLang/catleg/actions
.. |License| image:: https://img.shields.io/badge/license-Apache%202.0-blue.svg
:target: https://github.com/CatalaLang/catleg/blob/main/LICENSE

.. toctree::
:maxdepth: 3
:caption: Contents:

installation
cli_reference.md


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
44 changes: 44 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. _installation:

==============
Installation
==============

``catleg`` is tested on Linux, macOS and Windows.

.. _installation_homebrew:


Using pip
=========

The `catleg package <https://pypi.org/project/catleg/>`__ can be installed using ``pip`` like so::

pip install catleg

.. _installation_pipx:

Using pipx
==========

`pipx <https://pypi.org/project/pipx/>`__ is a tool for installing Python command-line applications in their own isolated environments. You can use ``pipx`` to install the ``catleg`` command-line tool like this::

pipx install catleg

Providing Legifrance credentials
================================

``catleg`` uses the Legifrance API to access French legislative texts.

This API is authenticated and requires credentials, which may be obtained by registering on `the Piste portal <https://piste.gouv.fr/>`__.

To provide credentials to catleg, create a ``.catleg_secrets.toml`` file like so::

lf_client_id = "your_client_id"
lf_client_secret = "your_client_secret"

Alternatively, you may define the environment variables ``CATLEG_LF_CLIENT_ID`` and ``CATLEG_LF_CLIENT_SECRET``.

.. note::
Legifrance authentication requires **oauth** credentials, not an API key.

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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ dynamic = ["version"]

[project.optional-dependencies]
dev = [
"hatch",
"mypy",
"myst-parser",
"pre-commit",
"pytest",
"ruff",
"sphinx",
"sphinx-rtd-theme",
"tox",
"typer-cli"
]

[project.scripts]
Expand Down

0 comments on commit 7dc48b2

Please sign in to comment.