Skip to content

Commit 8237a93

Browse files
feat: add developer docs (#328)
Adds a hidden statcan.github.io/dev wiki, which does not hold any original content, but instead scrapes all statcan repos (and applies a blacklist to remove ones that don't seem interesting) and wgets the README, CHANGELOG, and DEVELOPMENT files.
1 parent 1bac44a commit 8237a93

File tree

7 files changed

+138
-1
lines changed

7 files changed

+138
-1
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ jobs:
1313
python-version: 3.8
1414
- name: Install dependencies
1515
run: |
16+
apt-get install --yes jq curl wget
1617
python -m pip install --upgrade pip
1718
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
1819
- name: Build
1920
run: |
2021
mkdocs build -c -f mkdocs-en.yml
2122
mkdocs build -c -f mkdocs-fr.yml
23+
bash build-dev-docs.sh
24+
mkdocs build -c -f mkdocs-dev.yml
2225
cp docs/index.html site/
2326
- name: Publish
2427
uses: peaceiris/actions-gh-pages@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ node_modules
44
package-lock.json
55
site
66
yarn-error.log
7+
docs/dev/*
8+
!docs/dev/index.md

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
README.md
22
CHANGELOG.md
3-
.venv/
3+
docs/dev/
4+
build-dev-docs.sh
5+
.venv/

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ serve-en:
5858
serve-fr:
5959
. .venv/bin/activate && mkdocs serve -f mkdocs-fr.yml
6060

61+
serve-dev:
62+
bash build-dev-docs.sh
63+
. .venv/bin/activate && mkdocs serve -f mkdocs-dev.yml
64+
6165
test: check-format check-spelling
6266

6367
.PHONY: \

build-dev-docs.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
# NOTE/WARNING: This will break once we go over 100 repos.
4+
# Then we'll need to introduce pagination.
5+
6+
7+
ORG=StatCan
8+
DOCS_DIR=docs/dev/
9+
10+
camelcase () {
11+
echo $@ | tr '-' ' ' | sed 's/[^ ]\+/\L\u&/g'
12+
}
13+
14+
15+
# Repo blacklist
16+
ignore () {
17+
cat <<EOF | grep -q "$1"
18+
block-sequence
19+
cae-eac
20+
ccei
21+
census_age65_vs_population_growth
22+
census_birthplace
23+
census_income
24+
census_occupations
25+
dataviz-components
26+
dns
27+
EpiSim
28+
ESM-Mobile-App
29+
experimental-react-native-app
30+
experimental_data_api
31+
express-api-server
32+
jsonapi-pagination
33+
jstree
34+
katacoda-courses
35+
MetaTagGenerator
36+
orbital-viz
37+
pg-evolve
38+
site-ccei
39+
time-series-library
40+
transportation
41+
website
42+
wellBeingCheck
43+
WellbeingCheckChangeRequest
44+
WellbeingCheckUAT
45+
wellbeing_react_native
46+
EOF
47+
}
48+
49+
50+
let NUM_REPOS=$(curl --silent 'https://api.github.com/users/statcan' | jq -r .public_repos)
51+
52+
echo "Total number of repos: $NUM_REPOS"
53+
echo "Fetching all READMEs. This might take a minute."
54+
{
55+
let i=1
56+
while [ $NUM_REPOS -gt 0 ]; do
57+
let "NUM_REPOS-=50"
58+
echo curl --silent "https://api.github.com/users/statcan/repos?per_page=50&page=$i" >&2
59+
curl --silent "https://api.github.com/users/statcan/repos?per_page=50&page=$i"
60+
((i++))
61+
done
62+
} | jq -cr '.[] | @text "\(.name) \(.url)"' |
63+
while IFS=" " read name url; do
64+
# Keep a blacklist of repos
65+
ignore $name && continue
66+
67+
NAME=$(camelcase $name)
68+
mkdir -p "$DOCS_DIR/$NAME/"
69+
for f in CHANGELOG.md README.md DEVELOPMENT.md; do
70+
# If the file exists, then write it to file and
71+
# prepend the filename.
72+
wget --quiet https://raw.githubusercontent.com/$ORG/$name/master/$f -O "$DOCS_DIR/$NAME/$f.tmp"
73+
if [ -s "$DOCS_DIR/$NAME/$f.tmp" ]; then
74+
cat <<EOF > "$DOCS_DIR/$NAME/$f"
75+
Link: [$name]($url)
76+
77+
$(cat "$DOCS_DIR/$NAME/$f.tmp")
78+
EOF
79+
fi
80+
rm "$DOCS_DIR/$NAME/$f.tmp"
81+
done
82+
done

docs/dev/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AAW Dev docs
2+
3+
Everything here is simply scraped from the respective repos.
4+
5+
This content is not "curated".

mkdocs-dev.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
site_name: AAW Dev Docs
2+
site_url: https://statcan.github.io/daaas/en/
3+
site_description: Developer Docs
4+
copyright: Copyright &copy; 2020 Statistics Canada
5+
6+
docs_dir: docs/dev
7+
site_dir: site/dev
8+
9+
repo_name: statcan/daaas
10+
repo_url: https://github.com/statcan/daaas
11+
edit_uri: edit/master/docs/dev
12+
13+
theme:
14+
name: material
15+
language: en
16+
#features:
17+
# - tabs
18+
palette:
19+
primary: indigo
20+
accent: teal
21+
show_sidebar: false
22+
#logo: images/statcan.png
23+
24+
markdown_extensions:
25+
- toc:
26+
baselevel: 2
27+
permalink: true
28+
- attr_list
29+
- admonition
30+
- codehilite
31+
- mdx_truly_sane_lists
32+
- pymdownx.details
33+
34+
extra:
35+
social:
36+
- icon: fontawesome/brands/github-alt
37+
link: https://github.com/statcan/daaas
38+
- icon: fontawesome/brands/slack
39+
link: https://statcan-aaw.slack.com

0 commit comments

Comments
 (0)