Skip to content

Commit 5da8799

Browse files
authored
Feature/read the docs (#38)
* basic autogenerated docs * docs wip * update category docs * update docs for each namespace * fix format, include module in sphinx conf * fix broken import when building docs * fix broken import when building docs * fix build with local import * update readme * update ci deps
1 parent 7a8ae40 commit 5da8799

20 files changed

+259
-128
lines changed

.readthedocs.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-22.04"
5+
tools:
6+
python: "3.10"
7+
8+
python:
9+
install:
10+
- requirements: docs/requirements.txt
11+
12+
sphinx:
13+
configuration: docs/source/conf.py

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
[![PyPI version](https://badge.fury.io/py/fred-py-api.svg)](https://badge.fury.io/py/fred-py-api)
2+
[![Documentation Status](https://readthedocs.org/projects/fred-py-api/badge/?version=latest)](https://fred-py-api.readthedocs.io/en/latest/?badge=latest)
23
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/fred-py-api?style=flat)](https://pypi.org/project/fred-py-api/)
34
[![codecov](https://codecov.io/gh/zachspar/fred-py-api/branch/main/graph/badge.svg?token=BG1948D8Y7)](https://codecov.io/gh/zachspar/fred-py-api)
45

56
# Fred Python API
67
A fully-featured FRED Command Line Interface & Python API Wrapper.
78

8-
## Documentation:
9+
### Documentation:
10+
- [fred-py-api Docs](https://fred-py-api.readthedocs.io/en/latest/)
11+
12+
### Wiki:
913
- [fred-py-api Wiki](https://github.com/zachspar/fred-py-api/wiki)
1014

1115
### FRED References:

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
click>=7.0
2+
requests>=2.17.3
3+
sphinx==7.2.6
4+
sphinx-rtd-theme==1.3.0rc1

docs/source/categories.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Categories
2+
==========
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.categories
8+
:members:

docs/source/conf.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
import os
9+
import sys
10+
11+
sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "src")))
12+
13+
project = "fred-py-api"
14+
copyright = "2024, Zachary Spar"
15+
author = "Zachary Spar"
16+
release = "1.1.3"
17+
18+
# -- General configuration ---------------------------------------------------
19+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20+
21+
extensions = [
22+
"sphinx.ext.duration",
23+
"sphinx.ext.doctest",
24+
"sphinx.ext.autodoc",
25+
"sphinx.ext.napoleon",
26+
"sphinx.ext.autosummary",
27+
"sphinx.ext.intersphinx",
28+
]
29+
30+
intersphinx_mapping = {
31+
"python": ("https://docs.python.org/3/", None),
32+
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
33+
}
34+
35+
intersphinx_disabled_domains = ["std"]
36+
37+
templates_path = ["_templates"]
38+
39+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
40+
41+
# -- Options for HTML output -------------------------------------------------
42+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
43+
44+
html_theme = "alabaster"
45+
html_static_path = ["_static"]

docs/source/exceptions.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Exceptions
2+
==========
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.exceptions
8+
:members:

docs/source/index.rst

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.. fred-py-api documentation master file, created by
2+
sphinx-quickstart on Fri Mar 22 14:55:11 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to fred-py-api's documentation!
7+
=======================================
8+
9+
.. toctree::
10+
:maxdepth: 3
11+
:caption: Contents:
12+
13+
categories
14+
releases
15+
series
16+
sources
17+
tags
18+
19+
20+
Indices and tables
21+
==================
22+
23+
* :ref:`genindex`
24+
* :ref:`modindex`
25+
* :ref:`search`

docs/source/releases.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Releases
2+
========
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.releases
8+
:members:

docs/source/series.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Series
2+
======
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.series
8+
:members:

docs/source/sources.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Sources
2+
=======
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.sources
8+
:members:

docs/source/tags.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Tags
2+
====
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
.. automodule:: fred.api.tags
8+
:members:

fred.rb

-62
This file was deleted.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "fred-py-api"
7-
version = "1.1.2"
7+
version = "1.1.3"
88
authors = [
99
{ name="Zachary Spar", email="[email protected]" },
1010
{ name="Prasiddha Parthsarthy", email="[email protected]" },
@@ -39,6 +39,7 @@ dev = [
3939
"black==22.6.0",
4040
"coverage==6.4.2",
4141
"tox==3.25.1",
42+
"sphinx==7.2.6"
4243
]
4344

4445
[project.scripts]

src/fred/api/categories.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ class FredAPICategories(FredClient):
1111
Fred API Categories Namespace.
1212
1313
Endpoints:
14-
fred/category - Get a category. https://fred.stlouisfed.org/docs/api/fred/category.html
15-
fred/category/children - Get the child categories for a specified parent category. https://fred.stlouisfed.org/docs/api/fred/category_children.html
16-
fred/category/related - Get the related categories for a category. https://fred.stlouisfed.org/docs/api/fred/category_related.html
17-
fred/category/series - Get the series in a category. https://fred.stlouisfed.org/docs/api/fred/category_series.html
18-
fred/category/tags - Get the tags for a category. https://fred.stlouisfed.org/docs/api/fred/category_tags.html
19-
fred/category/related_tags - Get the related tags for a category. https://fred.stlouisfed.org/docs/api/fred/category_related_tags.html
14+
* `fred/category - Get a category <https://fred.stlouisfed.org/docs/api/fred/category.html>`_.
15+
* `fred/category/children - Get the child categories for a specified parent category <https://fred.stlouisfed.org/docs/api/fred/category_children.html>`_.
16+
* `fred/category/related - Get the related categories for a category <https://fred.stlouisfed.org/docs/api/fred/category_related.html>`_.
17+
* `fred/category/series - Get the series in a category <https://fred.stlouisfed.org/docs/api/fred/category_series.html>`_.
18+
* `fred/category/tags - Get the tags for a category <https://fred.stlouisfed.org/docs/api/fred/category_tags.html>`_.
19+
* `fred/category/related_tags - Get the related tags for a category <https://fred.stlouisfed.org/docs/api/fred/category_related_tags.html>`_.
2020
"""
2121

2222
@validate_api_args("api_key", "file_type", "category_id")
2323
def get_category(self, category_id: int = None, **kwargs) -> JsonOrXml:
24-
"""Get category by ID. https://fred.stlouisfed.org/docs/api/fred/category.html"""
24+
"""`Get category by ID <https://fred.stlouisfed.org/docs/api/fred/category.html>`_."""
2525
return self._get(
2626
f"category",
2727
{
@@ -46,7 +46,7 @@ def get_category(self, category_id: int = None, **kwargs) -> JsonOrXml:
4646
"exclude_tag_names",
4747
)
4848
def get_category_series(self, category_id: int, **kwargs) -> JsonOrXml:
49-
"""Get category series by category ID. https://fred.stlouisfed.org/docs/api/fred/category_series.html"""
49+
"""`Get category series by category ID <https://fred.stlouisfed.org/docs/api/fred/category_series.html>`_."""
5050
return self._get(
5151
f"category/series",
5252
{
@@ -57,7 +57,7 @@ def get_category_series(self, category_id: int, **kwargs) -> JsonOrXml:
5757

5858
@validate_api_args("api_key", "file_type", "category_id", "realtime_start", "realtime_end")
5959
def get_category_children(self, category_id: int = None, **kwargs) -> JsonOrXml:
60-
"""Get category children by category ID. https://fred.stlouisfed.org/docs/api/fred/category_children.html"""
60+
"""`Get category children by category ID <https://fred.stlouisfed.org/docs/api/fred/category_children.html>`_."""
6161
return self._get(
6262
f"category/children",
6363
{
@@ -68,7 +68,7 @@ def get_category_children(self, category_id: int = None, **kwargs) -> JsonOrXml:
6868

6969
@validate_api_args("api_key", "file_type", "category_id", "realtime_start", "realtime_end")
7070
def get_category_related(self, category_id: int, **kwargs) -> JsonOrXml:
71-
"""Get category related by category ID. https://fred.stlouisfed.org/docs/api/fred/category_related.html"""
71+
"""`Get category related by category ID <https://fred.stlouisfed.org/docs/api/fred/category_related.html>`_."""
7272
return self._get(
7373
f"category/related",
7474
{
@@ -98,7 +98,7 @@ def get_category_related(self, category_id: int, **kwargs) -> JsonOrXml:
9898
"sort_order",
9999
)
100100
def get_category_tags(self, category_id: int, **kwargs) -> JsonOrXml:
101-
"""Get category tags by category ID. https://fred.stlouisfed.org/docs/api/fred/category_tags.html"""
101+
"""`Get category tags by category ID <https://fred.stlouisfed.org/docs/api/fred/category_tags.html>`_."""
102102
return self._get(
103103
f"category/tags",
104104
{
@@ -129,7 +129,7 @@ def get_category_tags(self, category_id: int, **kwargs) -> JsonOrXml:
129129
"sort_order",
130130
)
131131
def get_category_related_tags(self, category_id: int, tag_names: str, **kwargs) -> JsonOrXml:
132-
"""Get category related tags by category ID and tag names. https://fred.stlouisfed.org/docs/api/fred/category_related_tags.html"""
132+
"""`Get category related tags by category ID and tag names <https://fred.stlouisfed.org/docs/api/fred/category_related_tags.html>`_."""
133133
return self._get(
134134
f"category/related_tags",
135135
{

0 commit comments

Comments
 (0)