Skip to content

Commit 1010320

Browse files
authored
Merge pull request #21 from machow/docs-refactor
docs: stub out docs and add to CI
2 parents c29e3aa + 302709f commit 1010320

File tree

14 files changed

+434
-51
lines changed

14 files changed

+434
-51
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,44 @@ jobs:
5454
- name: Run tests
5555
run: |
5656
pytest pins -m fs_rsc
57+
58+
build-docs:
59+
name: "Build Docs"
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- uses: actions/setup-python@v2
64+
65+
with:
66+
python-version: 3.8
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
python -m pip install -r requirements/dev.txt
71+
python -m pip install -e .
72+
- uses: r-lib/actions/setup-pandoc@v1
73+
with:
74+
pandoc-version: '2.17.0.1'
75+
- name: Build docs
76+
run: |
77+
make docs-build
78+
- name: Save docs artifact
79+
uses: actions/upload-artifact@v3
80+
with:
81+
name: docs-html
82+
path: docs/_build/html/
83+
84+
publish-docs:
85+
name: "Publish Docs"
86+
runs-on: ubuntu-latest
87+
needs: ["build-docs", "tests", "test-rsconnect"]
88+
if: github.ref == 'refs/heads/main'
89+
steps:
90+
- uses: actions/download-artifact@v3
91+
with:
92+
name: docs-html
93+
path: docs-html
94+
- uses: peaceiris/actions-gh-pages@v3
95+
with:
96+
github_token: ${{ secrets.GITHUB_TOKEN }}
97+
publish_dir: docs-html

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ docs-build:
2828

2929
docs-watch:
3030
cd docs && sphinx-autobuild . ./_build/html $(SPHINX_BUILDARGS)
31+
32+
docs-clean:
33+
rm -rf docs/_build docs/api/api_card
34+
35+
requirements-dev:
36+
@# allows you to do this...
37+
@# make requirements | tee > requirements/some_file.txt
38+
@pip-compile setup.cfg --rebuild --extra dev --output-file=-

docs/api/api_card/pins.BaseBoard.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@
1616
~BaseBoard.__init__
1717
~BaseBoard.construct_path
1818
~BaseBoard.keep_final_path_component
19+
~BaseBoard.path_to_deploy_version
1920
~BaseBoard.path_to_pin
21+
~BaseBoard.pin_browse
22+
~BaseBoard.pin_delete
23+
~BaseBoard.pin_download
2024
~BaseBoard.pin_exists
2125
~BaseBoard.pin_fetch
2226
~BaseBoard.pin_list
2327
~BaseBoard.pin_meta
2428
~BaseBoard.pin_read
29+
~BaseBoard.pin_search
30+
~BaseBoard.pin_upload
31+
~BaseBoard.pin_version_delete
2532
~BaseBoard.pin_versions
33+
~BaseBoard.pin_versions_prune
2634
~BaseBoard.pin_write
35+
~BaseBoard.prepare_pin_version
36+
~BaseBoard.sort_pin_versions
2737
~BaseBoard.validate_pin_name

docs/api/boards.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,28 @@ Constructor
1111

1212
BaseBoard
1313

14-
Methods
15-
-------
14+
Methods (Implemented)
15+
---------------------
1616

1717
.. autosummary::
1818
:toctree: api_card/
1919

20-
BaseBoard.pin_list
21-
BaseBoard.pin_versions
22-
BaseBoard.pin_meta
23-
BaseBoard.pin_read
24-
BaseBoard.pin_exists
20+
~BaseBoard.pin_read
21+
~BaseBoard.pin_write
22+
~BaseBoard.pin_meta
23+
~BaseBoard.pin_versions
24+
~BaseBoard.pin_list
25+
~BaseBoard.pin_exists
26+
27+
Methods (Planned)
28+
-----------------
29+
.. autosummary::
30+
:toctree: api_card/
31+
32+
~BaseBoard.pin_download
33+
~BaseBoard.pin_upload
34+
~BaseBoard.pin_version_delete
35+
~BaseBoard.pin_versions_prune
36+
~BaseBoard.pin_search
37+
~BaseBoard.pin_delete
38+
~BaseBoard.pin_browse

docs/api/filesystem.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
File System
2+
===========
3+
4+
.. currentmodule:: pins.boards
5+
6+
Constructor
7+
-----------
8+
9+
.. autosummary::
10+
:toctree: api_card/
11+
12+
IFileSystem
13+
14+
15+
Methods
16+
-------
17+
18+
.. autosummary::
19+
:toctree: api_card/
20+
21+
IFileSystem.exists
22+
IFileSystem.info
23+
IFileSystem.ls
24+
IFileSystem.open
25+
IFileSystem.put
26+
IFileSystem.get
27+
IFileSystem.mkdir
28+
IFileSystem.rm

docs/api/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ API
55
:maxdepth: 2
66

77
boards
8+
meta
9+
filesystem

docs/api/meta.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Metadata
2+
========
3+
4+
.. currentmodule:: pins
5+
6+
.. autosummary::
7+
:toctree: api_card/
8+
9+
meta.Meta
10+
meta.MetaFactory
11+
versions.VersionRaw
12+
versions.Version

docs/conf.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929
# ones.
3030
extensions = [
31+
"sphinx.ext.napoleon",
3132
"sphinx.ext.autodoc",
3233
"sphinx.ext.autosummary",
34+
"nbsphinx",
3335
]
3436

3537
# Add any paths that contain templates here, relative to this directory.
@@ -38,7 +40,17 @@
3840
# List of patterns, relative to source directory, that match files and
3941
# directories to ignore when looking for source files.
4042
# This pattern also affects html_static_path and html_extra_path.
41-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
43+
exclude_patterns = [
44+
"_build",
45+
"Thumbs.db",
46+
".DS_Store",
47+
"**.ipynb_checkpoints",
48+
"**.swp",
49+
"draft*",
50+
"scripts",
51+
".*swp",
52+
".~*.ipynb",
53+
]
4254

4355

4456
# -- Options for HTML output -------------------------------------------------
@@ -52,3 +64,16 @@
5264
# relative to this directory. They are copied after the builtin static files,
5365
# so a file named "default.css" will overwrite the builtin "default.css".
5466
html_static_path = ["_static"]
67+
68+
# -- Options for numpydoc ---
69+
napoleon_use_admonition_for_notes = True
70+
numpydoc_attributes_as_param_list = False
71+
72+
73+
# -- Jupytext ---
74+
import jupytext # noqa
75+
76+
77+
nbsphinx_custom_formats = {
78+
".Rmd": lambda s: jupytext.reads(s, ".Rmd"),
79+
}

docs/getting_started.Rmd

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Getting Started
2+
===============
3+
4+
The pins package helps you publish data sets, models, and other R objects, making it easy to share them across projects and with your colleagues.
5+
You can pin objects to a variety of "boards", including local folders (to share on a networked drive or with dropbox), RStudio connect, Amazon S3, and more.
6+
This vignette will introduce you to the basics of pins.
7+
8+
```{python}
9+
import pins
10+
```
11+
12+
## Getting started
13+
14+
Every pin lives in a pin *board*, so you must start by creating a pin board.
15+
In this vignette I'll use a temporary board which is automatically deleted when your R session is over:
16+
17+
```{python}
18+
# TODO: simple board constructors
19+
import fsspec
20+
import tempfile
21+
22+
fs = fsspec.filesystem("file")
23+
tmp_dir = tempfile.TemporaryDirectory()
24+
25+
board = pins.BaseBoard(tmp_dir.name, fs)
26+
```
27+
28+
In real-life, you'd pick a board depending on how you want to share the data.
29+
Here are a few options:
30+
31+
```{python}
32+
# TODO
33+
# board <- board_local() # share data across R sessions on the same computer
34+
# board <- board_folder("~/Dropbox") # share data with others using dropbox
35+
# board <- board_folder("Z:\\my-team\pins") # share data using a shared network drive
36+
# board <- board_rsconnect() # share data with RStudio Connect
37+
```
38+
39+
## Reading and writing data
40+
41+
Once you have a pin board, you can write data to it with `pin_write()`:
42+
43+
```{python}
44+
from siuba.data import mtcars
45+
board.pin_write(mtcars, "mtcars", type="csv")
46+
```
47+
48+
The first argument is the object to save (usually a data frame, but it can be any R object), and the second argument gives the "name" of the pin.
49+
The name is basically equivalent to a file name: you'll use it when you later want to read the data from the pin.
50+
The only rule for a pin name is that it can't contain slashes.

docs/index.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@ Welcome to pins's documentation!
77
================================
88

99
.. toctree::
10+
:hidden:
1011
:maxdepth: 2
1112
:caption: Contents:
1213

14+
getting_started
15+
user_guide/index
1316
api/index
14-
15-
16-
17-
Indices and tables
18-
==================
19-
20-
* :ref:`genindex`
21-
* :ref:`modindex`
22-
* :ref:`search`

0 commit comments

Comments
 (0)