Skip to content

Commit a4381ce

Browse files
authored
🎨 Move some build info from CI to general repository (#252)
2 parents 4127579 + d5a668e commit a4381ce

File tree

6 files changed

+86
-19
lines changed

6 files changed

+86
-19
lines changed

β€Ž.circleci/config.ymlβ€Ž

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ commands:
1414
name: ↑ Installing build dependencies
1515
command: |
1616
sudo apt-get update && sudo apt-get -y install git python3-dev graphviz graphviz-dev libgraphviz-dev pkg-config python3-sphinx
17+
pip install --user -r requirements.txt
1718
pip install --user -r https://raw.githubusercontent.com/FCP-INDI/C-PAC/<< parameters.version >>/requirements.txt
18-
pip install --user git+https://github.com/${CIRCLE_PROJECT_USERNAME}/C-PAC.git@<< parameters.version >> sphinx m2r numpydoc PyGithub "sphinxcontrib-bibtex<2.0" sphinxcontrib-fulltoc sphinxcontrib-programoutput semver torch
19+
pip install --user git+https://github.com/${CIRCLE_PROJECT_USERNAME}/C-PAC.git@<< parameters.version >>
1920
git clone https://github.com/${CIRCLE_PROJECT_USERNAME}/C-PAC.git /home/circleci/build/C-PAC
2021
cd /home/circleci/build/C-PAC
2122
git checkout << parameters.version >>
@@ -24,13 +25,6 @@ commands:
2425
source ~/simple/bin/activate
2526
pip install cpac
2627
deactivate
27-
- run:
28-
name: πŸ–‡οΈ Linking references
29-
command: |
30-
CPAC_DIRECTORY=$(python -c "import os, CPAC; print(os.path.abspath(os.path.dirname(CPAC.__file__)))")
31-
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-nesting-mappings.yml docs/_sources/references/1.7-1.8-nesting-mappings.yml || true
32-
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-deprecations.yml docs/_sources/references/1.7-1.8-deprecations.yml || true
33-
curl -o docs/_sources/references/default_pipeline.yml -L https://raw.githubusercontent.com/${CIRCLE_PROJECT_USERNAME}/C-PAC/<< parameters.version >>/dev/docker_data/default_pipeline.yml || true
3428
3529
run-cpac-commands:
3630
steps:
@@ -39,7 +33,7 @@ commands:
3933
name: πŸ‘Š Running cpac commands
4034
command: |
4135
source ~/simple/bin/activate
42-
cpac run --help
36+
cpac pull
4337
mkdir -p docs/_sources/user/cpac
4438
printf ".. code-block:: console\n\n $ cpac --help\n\n" > docs/_sources/user/cpac/help.rst
4539
cpac --help | sed -e "s/.*/ &/" >> docs/_sources/user/cpac/help.rst

β€ŽCONTRIBUTING.mdβ€Ž

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1+
<!-- TOC -->
2+
3+
- [Branches](#branches)
4+
- [Versions](#versions)
5+
- [`nightly`](#nightly)
6+
- [C-PAC release tags](#c-pac-release-tags)
7+
- [Guidelines](#guidelines)
8+
- [Building](#building)
9+
- [Let CircleCI build your drafts / works-in-progress](#let-circleci-build-your-drafts--works-in-progress)
10+
- [Build locally (C-PAC β‰₯ v1.8.0)](#build-locally-c-pac-β‰₯-v180)
11+
- [Flowcharts](#flowcharts)
12+
- [References and citations](#references-and-citations)
13+
- [Environment notes](#environment-notes)
14+
15+
<!-- /TOC -->
16+
17+
<a id="markdown-branches" name="branches"></a>
118
## Branches
219

320
Please, always base changes on the `source` branch. `master` branch will be overwritten by the CI deployment.
421

22+
<a id="markdown-versions" name="versions"></a>
523
### Versions
624

25+
<a id="markdown-nightly" name="nightly"></a>
726
#### `nightly`
827

928
Pushes to `source` will rebuild docs at https://fcp-indi.github.io/docs/nightly
1029

30+
<a id="markdown-c-pac-release-tags" name="c-pac-release-tags"></a>
1131
#### C-PAC release tags
1232
Tags in the format `v.*-source` will build docs for the given version.
1333

@@ -21,6 +41,7 @@ Steps to build a release:
2141
5. (Force) push to the remote tag (`git push origin v`version`-source`).
2242
6. CircleCI should deploy the versioned documentation. If the version tag is the newest, it should also overwrite `latest` with these documents.
2343

44+
<a id="markdown-guidelines" name="guidelines"></a>
2445
## Guidelines
2546

2647
- Only write a document once, and liberally use the [reStructured Text `.. include::` directive](https://docutils.sourceforge.io/docs/ref/rst/directives.html#include) to include that document where appropriate.
@@ -37,16 +58,50 @@ Steps to build a release:
3758
'
3859
"
3960
```
40-
- Let CircleCI build your drafts / works-in-progress
41-
* Build environment will match actual docs build environment
42-
* CircleCI takes ~2 minutes to build
43-
1. Fork https://github.com/FCP-INDI/fcp-indi.github.com
44-
1. In your fork's settings, set the GitHub Pages `source` to `master` branch
45-
![GitHub Pages settings example screenshot](./images/github-pages-settings-example.png)
46-
1. Add your project on CircleCI
47-
1. Merge your draft / work-in-progress into your fork's `source` branch. Make sure you push to your fork and not the main repository's `source` branch.
48-
1. Your fork will publish at `https://[your_GitHub_username].github.io/fcp-indi.github.com/`.
4961

62+
<a id="markdown-building" name="building"></a>
63+
### Building
64+
65+
<a id="markdown-let-circleci-build-your-drafts--works-in-progress" name="let-circleci-build-your-drafts--works-in-progress"></a>
66+
#### Let CircleCI build your drafts / works-in-progress
67+
* Build environment will match actual docs build environment
68+
* CircleCI takes ~2 minutes to build
69+
1. Fork https://github.com/FCP-INDI/fcp-indi.github.com
70+
1. In your fork's settings, set the GitHub Pages `source` to `master` branch
71+
![GitHub Pages settings example screenshot](./images/github-pages-settings-example.png)
72+
1. Add your project on CircleCI
73+
1. Merge your draft / work-in-progress into your fork's `source` branch. Make sure you push to your fork and not the main repository's `source` branch.
74+
1. Your fork will publish at `https://[your_GitHub_username].github.io/fcp-indi.github.com/`.
75+
76+
<a id="markdown-build-locally-c-pac-β‰₯-v180" name="build-locally-c-pac-β‰₯-v180"></a>
77+
#### Build locally (C-PAC β‰₯ v1.8.0)
78+
This documentation aspires to rely on a [single source of truth](https://en.wikipedia.org/wiki/Single_source_of_truth) where possible. To this end, building this documentation requires an installation of the version of [C-PAC](https://github.com/FCP-INDI/C-PAC) that is being documented.
79+
80+
Steps to build this documentation locally:
81+
1. Clone this repository.
82+
1. _(optional)_ <details><summary>Locally replicate the step "πŸ‘Š Running cpac commands" from [.circleci/config](./.circleci/config) to generate [cpac](https://pypi.org/project/cpac/) usage strings.</summary>
83+
Either perform this "πŸ‘Š Running cpac commands" step in a separate Python environment or uninstall cpac after generating the usage string(s).
84+
1. _(optional)_ Create an environment for cpac and activate this environment.
85+
1. `pip install cpac`
86+
1. If you don't have a local container for the version of C-PAC you're documenting, `cpac pull` to download the latest or `cpac pull --tag $TAG` to pull a specific version.
87+
1. Generate ReStructuredText documents with cpac usage strings:
88+
```BASH
89+
mkdir -p docs/_sources/user/cpac
90+
printf ".. code-block:: console\n\n $ cpac --help\n\n" > docs/_sources/user/cpac/help.rst
91+
cpac --help | sed -e "s/.*/ &/" >> docs/_sources/user/cpac/help.rst
92+
mkdir -p docs/_sources/user/run
93+
printf "Usage: cpac run\n\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\n.. code-block:: console\n\n $ cpac run --help\n\n" > docs/_sources/user/run/help.rst
94+
cpac run --help | sed -e "s/.*/ &/" >> docs/_sources/user/run/help.rst
95+
mkdir -p docs/_sources/user/utils
96+
printf "Usage: cpac utils\n\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\n.. code-block:: console\n\n $ cpac utils --help\n\n" > docs/_sources/user/utils/help.rst
97+
cpac utils --help | sed -e "s/.*/ &/" >> docs/_sources/user/utils/help.rst
98+
```
99+
1. `deactivate` your cpac environment if you used a separate environment or `pip uninstall cpac`.
100+
</details>
101+
1. Locally install [C-PAC](https://github.com/FCP-INDI/C-PAC) from source.
102+
1. Run `./bin/build $VERSION` where `$VERSION` is the version to build (`nightly`, `latest`, or [<span title='Semantic Versioning'>semver</span>](https://semver.org/) for production, but this string can be anything you want locally). ![example version](./images/example_version.png)
103+
104+
<a id="markdown-flowcharts" name="flowcharts"></a>
50105
## Flowcharts
51106

52107
- SVGs exported from Lucidchart have scaling coded in in `width` and `height` XML attributes. Add the XML attributes `preserveAspectRatio="xMinYMin meet"` and `viewBox` to the SVG element in the actual SVG files:
@@ -64,6 +119,7 @@ where `{width}` and `{height}` are the values already present in the existing `w
64119
<object data="../_static/path/to/chart.svg" type="image/svg+xml"></object>
65120
```
66121

122+
<a id="markdown-references-and-citations" name="references-and-citations"></a>
67123
## References and citations
68124

69125
[sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/) is installed and configured. This extension creates links between the citations and the reference in the reference list and formats citations in referenced BibTeX files using built-in or [custom styles](https://github.com/FCP-INDI/fcp-indi.github.com/blob/source/docs/_sources/references/style.py). To use this Sphinx extension,
@@ -114,6 +170,7 @@ The rendered file should look something like
114170
>
115171
> <a name="ref1" href="#backref1">[1]</a> Craddock, C., Sikka, S., Cheung, B., Khanuja, R., Ghosh, S. S., Yan, C., Li, Q., Lurie, D., Vogelstein, J., Burns, R., Colcombe, S., Mennes, M., Kelly, C., Di Martino, A., Castellanos, F. X., and Milham, M. 2013. [Towards automated analysis of connectomes: the Configurable Pipeline for the Analysis of Connectomes (C-PAC).](http://www.frontiersin.org/neuroinformatics/10.3389/conf.fninf.2013.09.00042/full) *Frontiers in neuroinformatics* 42. doi:[10.3389/conf.fninf.2013.09.00042](https://dx.doi.org/10.3389/conf.fninf.2013.09.00042)
116172

173+
<a id="markdown-environment-notes" name="environment-notes"></a>
117174
## Environment notes
118175
* Because [C-PAC](https://github.com/FCP-INDI/C-PAC.git) and [cpac](https://github.com/FCP-INDI/cpac.git) have conflicting commandline commands, we first run any `cpac` commands in a virtual environment and spoof the `command-output` directive with `code-block` like
119176
```RST

β€Žbin/buildβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
#!/bin/bash
22

3+
# link references
4+
CPAC_DIRECTORY=$(python -c "import os, CPAC; print(os.path.abspath(os.path.dirname(CPAC.__file__)))")
5+
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-nesting-mappings.yml docs/_sources/references/1.7-1.8-nesting-mappings.yml || true
6+
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-deprecations.yml docs/_sources/references/1.7-1.8-deprecations.yml || true
7+
ln ${CPAC_DIRECTORY}/resources/configs/default_pipeline.yml docs/_sources/references/default_pipeline.yml || true
8+
9+
# build docs
310
sphinx-build -b html docs/_sources docs/$1

β€Ždocs/_sources/conf.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
sys.path.append(os.path.dirname(__file__))
2929

30-
from references import CPAC_DocsStyle
30+
from references import CPAC_DocsStyle # noqa: E402
3131

3232
register_plugin('pybtex.style.formatting', 'cpac_docs_style', CPAC_DocsStyle)
3333

β€Žimages/example_version.pngβ€Ž

39.9 KB
Loading

β€Žrequirements.txtβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
m2r
2+
numpydoc
3+
PyGithub
4+
sphinx
5+
sphinxcontrib-bibtex<2.0
6+
sphinxcontrib-fulltoc
7+
sphinxcontrib-programoutput
8+
semver
9+
torch

0 commit comments

Comments
Β (0)