Skip to content

Commit e751a42

Browse files
Merge pull request #1016 from zitrosolrac/newDocApiSite
Doc API site
2 parents f5fc2f6 + 9575bea commit e751a42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+452
-257
lines changed

.github/workflows/development.yaml

Lines changed: 55 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,41 @@ 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+
cd gh-pages
97+
git config --local user.email "[email protected]"
98+
git config --local user.name "GitHub Action"
99+
git add . --all
100+
git commit -m "Update documentation" -a || true
101+
# The above command will fail if no changes were present, so we ignore
102+
# the return code.
103+
- name: Push changes
104+
uses: ad-m/github-push-action@master
105+
with:
106+
branch: gh-pages
107+
directory: gh-pages
108+
github_token: ${{secrets.GITHUB_TOKEN}}

.nojekyll

Whitespace-only changes.

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -247,6 +248,7 @@ def set_query_cache(self, query_cache=None):
247248
1. Only SELECT queries are allowed.
248249
2. The results of queries are cached under the path indicated by dj.config['query_cache']
249250
3. query_cache is a string that differentiates different cache states.
251+
250252
:param query_cache: a string to initialize the hash for query results
251253
"""
252254
self._query_cache = query_cache
@@ -298,6 +300,7 @@ def query(
298300
):
299301
"""
300302
Execute the specified query and return the tuple generator (cursor).
303+
301304
:param query: SQL query
302305
:param args: additional arguments for the client.cursor
303306
: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

datajoint/external.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def upload_filepath(self, local_filepath):
300300
def download_filepath(self, filepath_hash):
301301
"""
302302
sync a file from external store to the local stage
303+
303304
:param filepath_hash: The hash (UUID) of the relative_path
304305
:return: hash (UUID) of the contents of the downloaded file or Nones
305306
"""
@@ -351,6 +352,7 @@ def fetch_external_paths(self, **fetch_kwargs):
351352
"""
352353
generate complete external filepaths from the query.
353354
Each element is a tuple: (uuid, path)
355+
354356
:param fetch_kwargs: keyword arguments to pass to fetch
355357
"""
356358
fetch_kwargs.update(as_dict=True)
@@ -371,6 +373,7 @@ def fetch_external_paths(self, **fetch_kwargs):
371373
def unused(self):
372374
"""
373375
query expression for unused hashes
376+
374377
:return: self restricted to elements that are not in use by any tables in the schema
375378
"""
376379
return self - [
@@ -383,6 +386,7 @@ def unused(self):
383386
def used(self):
384387
"""
385388
query expression for used hashes
389+
386390
:return: self restricted to elements that in use by tables in the schema
387391
"""
388392
return self & [
@@ -401,9 +405,9 @@ def delete(
401405
errors_as_string=True
402406
):
403407
"""
404-
:param delete_external_files: True or False. If False, only the tracking info is removed from the
405-
external store table but the external files remain intact. If True, then the external files
406-
themselves are deleted too.
408+
409+
:param delete_external_files: True or False. If False, only the tracking info is removed from the external
410+
store table but the external files remain intact. If True, then the external files themselves are deleted too.
407411
:param errors_as_string: If True any errors returned when deleting from external files will be strings
408412
:param limit: (integer) limit the number of items to delete
409413
:param display_progress: if True, display progress as files are cleaned up
@@ -470,6 +474,7 @@ def __getitem__(self, store):
470474
"""
471475
Triggers the creation of an external table.
472476
Should only be used when ready to save or read from external storage.
477+
473478
:param store: the name of the store
474479
:return: the ExternalTable object for the store
475480
"""

0 commit comments

Comments
 (0)