Skip to content
This repository was archived by the owner on Aug 13, 2022. It is now read-only.

Commit 787dffc

Browse files
committed
Add sphinx
1 parent ce5e2e9 commit 787dffc

File tree

13 files changed

+543
-55
lines changed

13 files changed

+543
-55
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ benchmark-full:
101101
docs:
102102
make -C doc html
103103

104+
.PHONY: docs-apidoc
105+
docs-apidoc:
106+
sphinx-apidoc -o doc/source/api/ -H "API" rustcsv 'test_*'
107+
108+
.PHONY: docs-autobuild
109+
docs-autobuild:
110+
sphinx-autobuild -p 8001 doc/source/ doc/build/html/
111+
104112
# Release management
105113
# ==================
106114

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ isort = "*"
1515
colorlog = "*"
1616
pytest-benchmark = {version = "*", extras = ["histogram"]}
1717
hypothesis = "*"
18+
sphinx = "*"
19+
sphinx-autobuild = "*"
20+
sphinx-autodoc-typehints = "*"
1821

1922
[requires]
2023
python_version = "3.6"

Pipfile.lock

Lines changed: 209 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ fn main() {
55
let src = std::env::var("CARGO_MANIFEST_DIR").unwrap();
66
let dst = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).join("built.rs");
77
let mut opts = built::Options::default();
8-
opts.set_dependencies(true)
9-
.set_compiler(true)
10-
.set_env(true);
8+
opts.set_dependencies(true).set_compiler(true).set_env(true);
119
built::write_built_file_with_opts(&opts, src, dst)
1210
.expect("Failed to acquire build-time information");
1311
}

doc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

doc/Makefile

Lines changed: 20 additions & 0 deletions
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.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = rust-csv-py
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)

doc/make.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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=source
11+
set BUILDDIR=build
12+
set SPHINXPROJ=rust-csv-py
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd

doc/source/conf.py

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# This file does only contain a selection of the most common options. For a
6+
# full list see the documentation:
7+
# http://www.sphinx-doc.org/en/master/config
8+
9+
# -- Path setup --------------------------------------------------------------
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
# import os
16+
# import sys
17+
# sys.path.insert(0, os.path.abspath('.'))
18+
19+
20+
# -- Project information -----------------------------------------------------
21+
from pkg_resources import get_distribution
22+
23+
project = "rustcsv"
24+
copyright = "2018, Joar Wandborg"
25+
author = "Joar Wandborg"
26+
27+
# The short X.Y version
28+
version = "0.1"
29+
30+
# The full version, including alpha/beta/rc tags
31+
release = get_distribution("rustcsv").version
32+
33+
34+
# -- General configuration ---------------------------------------------------
35+
36+
# If your documentation needs a minimal Sphinx version, state it here.
37+
#
38+
# needs_sphinx = '1.0'
39+
40+
# Add any Sphinx extension module names here, as strings. They can be
41+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
42+
# ones.
43+
extensions = [
44+
"sphinx.ext.autodoc",
45+
"sphinx.ext.intersphinx",
46+
"sphinx.ext.viewcode",
47+
"sphinx.ext.napoleon",
48+
"sphinx_autodoc_typehints",
49+
]
50+
51+
# Add any paths that contain templates here, relative to this directory.
52+
templates_path = ["_templates"]
53+
54+
# The suffix(es) of source filenames.
55+
# You can specify multiple suffix as a list of string:
56+
#
57+
# source_suffix = ['.rst', '.md']
58+
source_suffix = ".rst"
59+
60+
# The master toctree document.
61+
master_doc = "index"
62+
63+
# The language for content autogenerated by Sphinx. Refer to documentation
64+
# for a list of supported languages.
65+
#
66+
# This is also used if you do content translation via gettext catalogs.
67+
# Usually you set "language" from the command line for these cases.
68+
language = None
69+
70+
# List of patterns, relative to source directory, that match files and
71+
# directories to ignore when looking for source files.
72+
# This pattern also affects html_static_path and html_extra_path .
73+
exclude_patterns = []
74+
75+
# The name of the Pygments (syntax highlighting) style to use.
76+
pygments_style = "sphinx"
77+
78+
79+
# -- Options for HTML output -------------------------------------------------
80+
81+
# The theme to use for HTML and HTML Help pages. See the documentation for
82+
# a list of builtin themes.
83+
#
84+
html_theme = "alabaster"
85+
86+
# Theme options are theme-specific and customize the look and feel of a theme
87+
# further. For a list of options available for each theme, see the
88+
# documentation.
89+
#
90+
# html_theme_options = {}
91+
92+
# Add any paths that contain custom static files (such as style sheets) here,
93+
# relative to this directory. They are copied after the builtin static files,
94+
# so a file named "default.css" will overwrite the builtin "default.css".
95+
html_static_path = ["_static"]
96+
97+
# Custom sidebar templates, must be a dictionary that maps document names
98+
# to template names.
99+
#
100+
# The default sidebars (for documents that don't match any pattern) are
101+
# defined by theme itself. Builtin themes are using these templates by
102+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
103+
# 'searchbox.html']``.
104+
#
105+
# html_sidebars = {}
106+
107+
108+
# -- Options for HTMLHelp output ---------------------------------------------
109+
110+
# Output file base name for HTML help builder.
111+
htmlhelp_basename = "rust-csv-pydoc"
112+
113+
114+
# -- Options for LaTeX output ------------------------------------------------
115+
116+
latex_elements = {
117+
# The paper size ('letterpaper' or 'a4paper').
118+
#
119+
# 'papersize': 'letterpaper',
120+
# The font size ('10pt', '11pt' or '12pt').
121+
#
122+
# 'pointsize': '10pt',
123+
# Additional stuff for the LaTeX preamble.
124+
#
125+
# 'preamble': '',
126+
# Latex figure (float) alignment
127+
#
128+
# 'figure_align': 'htbp',
129+
}
130+
131+
# Grouping the document tree into LaTeX files. List of tuples
132+
# (source start file, target name, title,
133+
# author, documentclass [howto, manual, or own class]).
134+
latex_documents = [
135+
(
136+
master_doc,
137+
"rust-csv-py.tex",
138+
"rust-csv-py Documentation",
139+
"Joar Wandborg",
140+
"manual",
141+
)
142+
]
143+
144+
145+
# -- Options for manual page output ------------------------------------------
146+
147+
# One entry per manual page. List of tuples
148+
# (source start file, name, description, authors, manual section).
149+
man_pages = [
150+
(master_doc, "rust-csv-py", "rust-csv-py Documentation", [author], 1)
151+
]
152+
153+
154+
# -- Options for Texinfo output ----------------------------------------------
155+
156+
# Grouping the document tree into Texinfo files. List of tuples
157+
# (source start file, target name, title, author,
158+
# dir menu entry, description, category)
159+
texinfo_documents = [
160+
(
161+
master_doc,
162+
"rust-csv-py",
163+
"rust-csv-py Documentation",
164+
author,
165+
"rust-csv-py",
166+
"One line description of project.",
167+
"Miscellaneous",
168+
)
169+
]
170+
171+
172+
# -- Extension configuration -------------------------------------------------
173+
174+
# -- Options for intersphinx extension ---------------------------------------
175+
176+
# Example configuration for intersphinx: refer to the Python standard library.
177+
intersphinx_mapping = {"https://docs.python.org/3": None}

doc/source/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. rust-csv-py documentation master file, created by
2+
sphinx-quickstart on Mon Sep 10 13:34:57 2018.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
rustcsv - rust-csv + PyO3
7+
=======================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
12+
./reader
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

doc/source/reader.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=========
2+
CSVReader
3+
=========
4+
5+
.. autoclass:: rustcsv.CSVReader
6+
7+
.. automethod:: __new__
8+
9+
.. py:class:: rustcsv.CSVReader(path_or_file, delimiter=None, terminator=None)
10+
11+
Creates a new CSVReader instance
12+
13+
Arguments:
14+
15+
``path_or_file`` (:class:`str` or :any:`binary file`)
16+
17+
- A :class:`str` path to a file.
18+
- A :any:`binary file` object,
19+
e.g. :class:`io.BytesIO` or ``open(path, "rb")``.
20+
21+
``delimiter`` (Optional :class:`bytes` of length 1)
22+
The CSV field delimiter.
23+
Defaults to ``b","`` if ``None``.
24+
``terminator`` (Optional :class:`bytes` of length 1)
25+
The CSV record terminator.
26+
Defaults to ``b"\n"`` if ``None``.

0 commit comments

Comments
 (0)