Skip to content

Commit 4e5833d

Browse files
Merge pull request #1225 from yambottle/contribusion.md
datajoint-python developer guide
2 parents ed6f5a9 + fe6e638 commit 4e5833d

File tree

15 files changed

+304
-124
lines changed

15 files changed

+304
-124
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ venv.bak/
144144
.ropeproject
145145

146146
# mkdocs documentation
147-
/site
147+
/docs/site
148148

149149
# mypy
150150
.mypy_cache/

CONTRIBUTION.md

Whitespace-only changes.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ DataJoint (https://datajoint.com).
139139
- [DataJoint Elements](https://datajoint.com/docs/elements/) - Catalog of example pipelines for neuroscience experiments
140140

141141
- Contribute
142-
- [Development Environment](https://datajoint.com/docs/core/datajoint-python/latest/develop/)
142+
- [Contribution Guidelines](https://datajoint.com/docs/about/contribute/)
143143

144-
- [Guidelines](https://datajoint.com/docs/about/contribute/)
144+
- [Developer Guide](https://datajoint.com/docs/core/datajoint-python/latest/develop/)

docs/.docker/Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/.docker/apk_requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/.markdownlint.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# https://github.com/DavidAnson/markdownlint
22
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
3+
MD007: false # Unordered list indentation
34
MD009: false # permit trailing spaces
45
MD013:
5-
line_length: "88" # Line length limits
6+
# previously we defined line_length to 88 which is better for python
7+
# but not for markdown
8+
line_length:
9+
- strict: false
610
tables: false # disable for tables
711
headings: false # disable for headings
8-
code_blocks: false # disable for code blocks
12+
MD029: false # Ordered list item prefix
913
MD030: false # Number of spaces after a list
14+
MD032: false # Lists should be surrounded by blank lines
1015
MD033: # HTML elements allowed
1116
allowed_elements:
1217
- "div"

docs/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3
2+
3+
WORKDIR /main
4+
COPY ./docs/pip_requirements.txt /main/docs/pip_requirements.txt
5+
COPY ./datajoint /main/datajoint/
6+
COPY ./pyproject.toml /main/pyproject.toml
7+
8+
RUN \
9+
# Install docs dependencies
10+
pip install --no-cache-dir -r /main/docs/pip_requirements.txt && \
11+
# Install datajoint
12+
pip install --no-cache-dir -e /main/
13+
14+
# Install dependencies first and use docker cache
15+
# modify docs content won't cause image rebuild
16+
COPY ./docs/ /main/docs/

docs/README.md

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,97 @@
1-
# Docs Contributions
1+
# Contribute to DataJoint Documentation
22

3-
Docs contributors should be aware of the following extensions, with the corresponding
4-
settings files, that were used in developing these docs:
3+
This is the home for DataJoint software documentation as hosted at https://datajoint.com/docs/core/datajoint-python/latest/
54

6-
- [MarkdownLinter](https://github.com/DavidAnson/markdownlint):
5+
## VSCode Linter Extensions and Settings
6+
7+
The following extensions were used in developing these docs, with the corresponding
8+
settings files:
9+
10+
- Recommended extensions are already specified in `.vscode/extensions.json`, it will ask you to install them when you open the project if you haven't installed them.
11+
- settings in `.vscode/settings.json`
12+
- [MarkdownLinter](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint):
713
- `.markdownlint.yaml` establishes settings for various
814
[linter rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
915
- `.vscode/settings.json` formatting on save to fix linting
1016

11-
- [CSpell](https://github.com/streetsidesoftware/vscode-spell-checker): `cspell.json`
17+
- [CSpell](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker): `cspell.json`
1218
has various ignored words.
1319

14-
- [ReWrap](https://github.com/stkb/Rewrap/): `.vscode/settings.json` allows toggling
20+
- [ReWrap](https://marketplace.visualstudio.com/items?itemName=stkb.rewrap): `.vscode/settings.json` allows toggling
1521
automated hard wrapping for files at 88 characters. This can also be keymapped to be
1622
performed on individual paragraphs, see documentation.
23+
24+
## With Virtual Environment
25+
26+
conda
27+
```bash
28+
conda create -n djdocs -y
29+
conda activate djdocs
30+
```
31+
venv
32+
```bash
33+
python -m venv .venv
34+
source .venv/bin/activate
35+
```
36+
37+
Then install the required packages:
38+
```bash
39+
# go to the repo's root directory to generate API docs
40+
# cd ~/datajoint-python/
41+
42+
# install mkdocs related requirements
43+
pip install -r ./docs/pip_requirements.txt
44+
# install datajoint, since API docs are generated from the package
45+
pip install -e .[dev]
46+
```
47+
48+
Run mkdocs at: http://127.0.0.1:8000/
49+
```bash
50+
# go to the repo's root directory to generate API docs
51+
# cd ~/datajoint-python/
52+
53+
# It will automatically reload the docs when changes are made
54+
mkdocs serve --config-file ./docs/mkdocs.yaml
55+
```
56+
57+
## With Docker
58+
59+
> We mostly use Docker to simplify docs deployment
60+
61+
Ensure you have `Docker` and `Docker Compose` installed.
62+
63+
Then run the following:
64+
```bash
65+
# It will automatically reload the docs when changes are made
66+
MODE="LIVE" docker compose up --build
67+
```
68+
69+
Navigate to http://127.0.0.1:8000/ to preview the changes.
70+
71+
This setup supports live-reloading so all that is needed is to save the markdown files
72+
and/or `mkdocs.yaml` file to trigger a reload.
73+
74+
## Mkdocs Warning Explanation
75+
76+
> TL;DR: We need to do it this way for hosting, please keep it as is.
77+
78+
```log
79+
INFO - Doc file 'index.md' contains an unrecognized relative link './develop', it was left as is. Did you mean
80+
'develop.md'?
81+
```
82+
83+
- We use reverse proxy to proxy our docs sites, here is the proxy flow:
84+
- You hit `datajoint.com/*` on your browser
85+
- It'll bring you to the reverse proxy server first, that you wouldn't notice
86+
- when your URL ends with:
87+
- `/` is the company page
88+
- `/docs/` is the landing/navigation page hosted by datajoint/datajoint-docs's github pages
89+
- `/docs/core/datajoint-python/` is the actual docs site hosted by datajoint/datajoint-python's github pages
90+
- `/docs/elements/element-*/` is the actual docs site hosted by each element's github pages
91+
92+
93+
```log
94+
WARNING - Doc file 'query/operators.md' contains a link '../../../images/concepts-operators-restriction.png', but
95+
the target '../../images/concepts-operators-restriction.png' is not found among documentation files.
96+
```
97+
- We use Github Pages to host our docs, the image references needs to follow the mkdocs's build directory structure, under `site/` directory once you run mkdocs.

docs/docker-compose.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
# MODE="LIVE|QA|BUILD" PACKAGE=datajoint UPSTREAM_REPO=https://github.com/datajoint/datajoint-python.git HOST_UID=$(id -u) docker compose -f docs/docker-compose.yaml up --build
2-
version: "2.4"
1+
# MODE="LIVE|QA|BUILD" PACKAGE=datajoint UPSTREAM_REPO=https://github.com/datajoint/datajoint-python.git docker compose up --build
32
services:
43
docs:
54
build:
6-
dockerfile: docs/.docker/Dockerfile
7-
context: ../
8-
args:
9-
- PACKAGE
10-
image: ${PACKAGE}_python-docs
5+
# some docs need to be dynamically generated from the datajoint PACKAGE
6+
context: ..
7+
dockerfile: docs/Dockerfile
8+
image: datajoint-python-docs
119
environment:
12-
- PACKAGE
13-
- UPSTREAM_REPO
14-
- MODE
10+
MODE: ${MODE:-LIVE} # specify mode: LIVE, QA, BUILD
11+
# specify package to generate API docs
12+
PACKAGE: ${PACKAGE:-datajoint}
13+
UPSTREAM_REPO: ${UPSTREAM_REPO:-https://github.com/datajoint/datajoint-python.git}
1514
volumes:
1615
- ..:/main
17-
user: ${HOST_UID}:anaconda
1816
ports:
19-
- 80:80
17+
- 8000:8000
2018
command:
21-
- sh
19+
- bash
2220
- -c
2321
- |
2422
set -e
2523
if echo "$${MODE}" | grep -i live &>/dev/null; then
26-
mkdocs serve --config-file ./docs/mkdocs.yaml -a 0.0.0.0:80
24+
mkdocs serve --config-file /main/docs/mkdocs.yaml -a 0.0.0.0:8000
2725
elif echo "$${MODE}" | grep -iE "qa|build" &>/dev/null; then
2826
git branch -D gh-pages || true
2927
git fetch $${UPSTREAM_REPO} gh-pages:gh-pages || true
30-
mike deploy --config-file ./docs/mkdocs.yaml -u $$(grep -oE '\d+\.\d+' /main/$${PACKAGE}/version.py) latest
31-
mike set-default --config-file ./docs/mkdocs.yaml latest
28+
mike deploy --ignore-remote-status --config-file /main/docs/mkdocs.yaml -u $$(grep -oP '\d+\.\d+' /main/$${PACKAGE}/version.py) latest
29+
# mike set-default --config-file /main/docs/mkdocs.yaml latest
3230
if echo "$${MODE}" | grep -i qa &>/dev/null; then
33-
mike serve --config-file ./docs/mkdocs.yaml -a 0.0.0.0:80
31+
mike serve --config-file /main/docs/mkdocs.yaml -a 0.0.0.0:8000
3432
fi
3533
else
3634
echo "Unexpected mode..."

docs/mkdocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ markdown_extensions:
139139
- toc:
140140
permalink: true
141141
- pymdownx.emoji:
142-
emoji_index: !!python/name:materialx.emoji.twemoji
143-
emoji_generator: !!python/name:materialx.emoji.to_svg
142+
emoji_index: !!python/name:material.extensions.emoji.twemoji
143+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
144144
options:
145145
custom_icons:
146146
- .overrides/.icons

0 commit comments

Comments
 (0)