Skip to content

Commit 518ba94

Browse files
committed
2 parents 88f1059 + 1b3fe08 commit 518ba94

27 files changed

+550
-45
lines changed

.github/workflows/development.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ on:
99
- '**' # every branch
1010
- '!stage*' # exclude branches beginning with stage
1111
jobs:
12+
build-docs:
13+
runs-on: ubuntu-latest
14+
env:
15+
DOCKER_CLIENT_TIMEOUT: "120"
16+
COMPOSE_HTTP_TIMEOUT: "120"
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Compile docs static artifacts
20+
run: |
21+
export HOST_UID=$(id -u)
22+
docker-compose -f ./docs-api/docker-compose.yaml up --exit-code-from docs-builder --build
23+
- name: Add docs static artifacts
24+
uses: actions/upload-artifact@v2
25+
with:
26+
name: docs-api-static
27+
path: docs-api/build/html
28+
retention-days: 1
1229
test:
1330
if: github.event_name == 'push' || github.event_name == 'pull_request'
1431
runs-on: ubuntu-latest
@@ -51,3 +68,42 @@ jobs:
5168
--count --max-complexity=62 --max-line-length=127 --statistics
5269
black datajoint --check -v
5370
black tests --check -v
71+
publish-docs:
72+
if: |
73+
github.event_name == 'push' &&
74+
(
75+
github.repository_owner == 'datajoint' ||
76+
github.repository_owner == 'datajoint-company' ||
77+
github.repository_owner == 'dj-sciops'
78+
)
79+
needs: build-docs
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Fetch docs static artifacts
84+
uses: actions/download-artifact@v2
85+
with:
86+
name: docs-api-static
87+
path: docs-api/build/html
88+
- name: Commit documentation changes
89+
run: |
90+
git clone https://github.com/${GITHUB_REPOSITORY}.git \
91+
--branch gh-pages --single-branch gh-pages
92+
rm -R gh-pages/*
93+
cp -r docs-api/build/html/* gh-pages/
94+
cp .gitignore gh-pages/
95+
touch gh-pages/.nojekyll
96+
echo "docs-api.datajoint.org" > gh-pages/CNAME
97+
cd gh-pages
98+
git config --local user.email "[email protected]"
99+
git config --local user.name "GitHub Action"
100+
git add . --all
101+
git commit -m "Update documentation" -a || true
102+
# The above command will fail if no changes were present, so we ignore
103+
# the return code.
104+
- name: Push changes
105+
uses: ad-m/github-push-action@master
106+
with:
107+
branch: gh-pages
108+
directory: gh-pages
109+
github_token: ${{secrets.GITHUB_TOKEN}}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ important DataJoint schema or records.
110110

111111
</details>
112112

113+
### API docs
114+
115+
The API documentation can be built using sphinx by running
116+
117+
``` bash
118+
pip install sphinx sphinx_rtd_theme
119+
(cd docs-api/sphinx && make html)
120+
```
121+
122+
Generated docs are written to `docs-api/docs/html/index.html`.
123+
More details in [docs-api/README.md](docs-api/README.md).
124+
113125
## Running Tests Locally
114126
<details>
115127
<summary>Click to expand details</summary>

datajoint/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
that any use of DataJoint leading to a publication be acknowledged in the publication.
1111
1212
Please cite:
13-
http://biorxiv.org/content/early/2015/11/14/031658
14-
http://dx.doi.org/10.1101/031658
13+
14+
- http://biorxiv.org/content/early/2015/11/14/031658
15+
- http://dx.doi.org/10.1101/031658
1516
"""
1617

1718
__author__ = "DataJoint Contributors"

datajoint/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def set_password(
2828
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
2929
"""
3030
view and kill database connections.
31+
3132
:param restriction: restriction to be applied to processlist
3233
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
3334
:param order_by: order by a single attribute or the list of attributes. defaults to 'id'.
@@ -86,6 +87,7 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
8687
def kill_quick(restriction=None, connection=None):
8788
"""
8889
Kill database connections without prompting. Returns number of terminated connections.
90+
8991
:param restriction: restriction to be applied to processlist
9092
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
9193

datajoint/attribute_adapter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ def attribute_type(self):
1818
def get(self, value):
1919
"""
2020
convert value retrieved from the the attribute in a table into the adapted type
21+
2122
:param value: value from the database
23+
2224
:return: object of the adapted type
2325
"""
2426
raise NotImplementedError("Undefined attribute adapter")
2527

2628
def put(self, obj):
2729
"""
2830
convert an object of the adapted type into a value that DataJoint can store in a table attribute
31+
2932
:param obj: an object of the adapted type
3033
:return: value to store in the database
3134
"""

datajoint/connection.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
This module contains the Connection class that manages the connection to the database,
3-
and the `conn` function that provides access to a persistent connection in datajoint.
2+
This module contains the Connection class that manages the connection to the database, and
3+
the ``conn`` function that provides access to a persistent connection in datajoint.
44
"""
55
import warnings
66
from contextlib import contextmanager
@@ -52,6 +52,7 @@ def connect_host_hook(connection_obj):
5252
def translate_query_error(client_error, query):
5353
"""
5454
Take client error and original query and return the corresponding DataJoint exception.
55+
5556
:param client_error: the exception raised by the client interface
5657
:param query: sql query with placeholders
5758
:return: an instance of the corresponding subclass of datajoint.errors.DataJointError
@@ -108,11 +109,9 @@ def conn(
108109
:param password: mysql password
109110
:param init_fun: initialization function
110111
:param reset: whether the connection should be reset or not
111-
:param use_tls: TLS encryption option. Valid options are: True (required),
112-
False (required no TLS), None (TLS prefered, default),
113-
dict (Manually specify values per
114-
https://dev.mysql.com/doc/refman/5.7/en/connection-options.html
115-
#encrypted-connection-options).
112+
:param use_tls: TLS encryption option. Valid options are: True (required), False
113+
(required no TLS), None (TLS prefered, default), dict (Manually specify values per
114+
https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#encrypted-connection-options).
116115
"""
117116
if not hasattr(conn, "connection") or reset:
118117
host = host if host is not None else config["database.host"]
@@ -247,6 +246,7 @@ def set_query_cache(self, query_cache=None):
247246
1. Only SELECT queries are allowed.
248247
2. The results of queries are cached under the path indicated by dj.config['query_cache']
249248
3. query_cache is a string that differentiates different cache states.
249+
250250
:param query_cache: a string to initialize the hash for query results
251251
"""
252252
self._query_cache = query_cache
@@ -298,6 +298,7 @@ def query(
298298
):
299299
"""
300300
Execute the specified query and return the tuple generator (cursor).
301+
301302
:param query: SQL query
302303
:param args: additional arguments for the client.cursor
303304
:param as_dict: If as_dict is set to True, the returned cursor objects returns

datajoint/declare.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def build_index_parser():
153153

154154
def is_foreign_key(line):
155155
"""
156+
156157
:param line: a line from the table definition
157158
:return: true if the line appears to be a foreign key definition
158159
"""
@@ -366,6 +367,7 @@ def prepare_declare(definition, context):
366367
def declare(full_table_name, definition, context):
367368
"""
368369
Parse declaration and generate the SQL CREATE TABLE code
370+
369371
:param full_table_name: full name of the table
370372
:param definition: DataJoint table definition
371373
:param context: dictionary of objects that might be referred to in the table
@@ -566,6 +568,7 @@ def substitute_special_type(match, category, foreign_key_sql, context):
566568
def compile_attribute(line, in_key, foreign_key_sql, context):
567569
"""
568570
Convert attribute definition from DataJoint format to SQL
571+
569572
:param line: attribution line
570573
:param in_key: set to True if attribute is in primary key set
571574
:param foreign_key_sql: the list of foreign key declarations to add to

datajoint/diagram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def __init__(self, source, context=None):
146146
def from_sequence(cls, sequence):
147147
"""
148148
The join Diagram for all objects in sequence
149+
149150
:param sequence: a sequence (e.g. list, tuple)
150151
:return: Diagram(arg1) + ... + Diagram(argn)
151152
"""

datajoint/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, *args):
3434
def suggest(self, *args):
3535
"""
3636
regenerate the exception with additional arguments
37+
3738
:param args: addition arguments
3839
:return: a new exception of the same type with the additional arguments
3940
"""

datajoint/expression.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def where_clause(self):
121121
def make_sql(self, fields=None):
122122
"""
123123
Make the SQL SELECT statement.
124+
124125
:param fields: used to explicitly set the select attributes
125126
"""
126127
return "SELECT {distinct}{fields} FROM {from_}{where}".format(
@@ -323,6 +324,7 @@ def __add__(self, other):
323324
def proj(self, *attributes, **named_attributes):
324325
"""
325326
Projection operator.
327+
326328
:param attributes: attributes to be included in the result. (The primary key is already included).
327329
:param named_attributes: new attributes computed or renamed from existing attributes.
328330
:return: the projected expression.
@@ -481,6 +483,7 @@ def aggr(self, group, *attributes, keep_all_rows=False, **named_attributes):
481483
"""
482484
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
483485
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
486+
484487
:param group: The query expression to be aggregated.
485488
:param keep_all_rows: True=keep all the rows from self. False=keep only rows that match entries in group.
486489
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
@@ -510,6 +513,7 @@ def head(self, limit=25, **fetch_kwargs):
510513
"""
511514
shortcut to fetch the first few entries from query expression.
512515
Equivalent to fetch(order_by="KEY", limit=25)
516+
513517
:param limit: number of entries
514518
:param fetch_kwargs: kwargs for fetch
515519
:return: query result
@@ -520,6 +524,7 @@ def tail(self, limit=25, **fetch_kwargs):
520524
"""
521525
shortcut to fetch the last few entries from query expression.
522526
Equivalent to fetch(order_by="KEY DESC", limit=25)[::-1]
527+
523528
:param limit: number of entries
524529
:param fetch_kwargs: kwargs for fetch
525530
:return: query result
@@ -561,6 +566,7 @@ def __contains__(self, item):
561566
"""
562567
returns True if the restriction in item matches any entries in self
563568
e.g. ``restriction in q1``.
569+
564570
:param item: any restriction
565571
(item in query_expression) is equivalent to bool(query_expression & item) but may be
566572
executed more efficiently.
@@ -907,6 +913,7 @@ def aggr(self, group, **named_attributes):
907913
"""
908914
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
909915
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
916+
910917
:param group: The query expression to be aggregated.
911918
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
912919
:return: The derived query expression

0 commit comments

Comments
 (0)