-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add circle check * add mkdocs check * remove missing docs from index * cleanup index a bit * add pip install * python3 * reconcile docs to index * install gulp * add missing docs to index * install locally * run gulp and build prod
- Loading branch information
1 parent
0d79526
commit 7031e32
Showing
4 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
shell: /bin/bash --login | ||
environment: | ||
TZ: "/usr/share/zoneinfo/UTC" | ||
docker: | ||
- image: circleci/python:3.6.5-jessie-node | ||
|
||
steps: | ||
- checkout | ||
- run: sudo pip install PyYAML | ||
- run: ./scripts/validate_mkdocs.py | ||
- run: ./scripts/reconcile_docs_to_index.bash | ||
- run: npm install gulp-cli | ||
- run: npm install gulp -D | ||
- run: ./node_modules/gulp/bin/gulp.js build-prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
pushd $(dirname $0) > /dev/null | ||
|
||
cd $(pwd -P)/.. | ||
|
||
doc_count=0 | ||
missing_count=0 | ||
|
||
function check_index { | ||
line=$(grep "$1" ./docs/mkdocs/mkdocs.yml) | ||
|
||
if [ -f "$1" ] && [ -z "$line" ]; then | ||
[[ 0 -eq $missing_count ]] && echo "Docs missing from the mkdocs.yml index:" | ||
((missing_count+=1)) | ||
echo "$missing_count: '$1'" | ||
fi | ||
} | ||
|
||
docs=$(find docs \( -path 'docs/mkdocs' \) -prune -o -type f -regex ".+\.md$") | ||
for doc in $docs; do | ||
((doc_count+=1)) | ||
check_index $doc | ||
done | ||
|
||
if [[ 0 -lt $missing_count ]]; then | ||
ratio=$((100 * $missing_count / $doc_count)) | ||
echo "Missing $missing_count / $doc_count: $ratio%" | ||
popd > /dev/null | ||
exit 1 | ||
fi | ||
|
||
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import print_function | ||
|
||
import yaml, os.path, sys, functools | ||
|
||
# from https://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python | ||
def eprint(*args, **kwargs): | ||
print(*args, file=sys.stderr, **kwargs) | ||
|
||
def parse_page_dict(errors_detected, kv): | ||
(header, pages) = kv | ||
if pages is None: | ||
eprint("section ", header, " is incomplete") | ||
return True | ||
else: | ||
return parse_page(errors_detected, pages) | ||
|
||
def parse_page_string(errors_detected, page): | ||
if "index.md" != page and (not os.path.isfile(page)): | ||
eprint("page ", page, " is not valid") | ||
return True | ||
else: | ||
return errors_detected | ||
|
||
def parse_page(errors_detected, page): | ||
"parse a page for existence" | ||
if isinstance(page, dict): | ||
return functools.reduce(parse_page_dict, page.items(), errors_detected) | ||
elif isinstance(page, list): | ||
return functools.reduce(parse_page, page, errors_detected) | ||
elif isinstance(page, str): | ||
return parse_page_string(errors_detected, page) | ||
else: | ||
return errors_detected | ||
|
||
stream = open("docs/mkdocs/mkdocs.yml", 'r') | ||
mkdocs = yaml.load_all(stream) | ||
errors_detected = False | ||
|
||
for doc in mkdocs: | ||
for k,v in doc.items(): | ||
if "pages" == k: | ||
errors_detected = parse_page(False, v) | ||
|
||
if errors_detected: | ||
sys.exit(1) |