Skip to content

Commit

Permalink
Updates docs site index (#174)
Browse files Browse the repository at this point in the history
* 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
jamesaimonetti authored and JRMaitre committed Apr 28, 2018
1 parent 0d79526 commit 7031e32
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .circleci/config.yml
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
22 changes: 15 additions & 7 deletions docs/mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
site_name: UI Development
theme_dir: 2600Hz_theme
pages:
- 'index.md'

pages:
- 'index.md'
Expand All @@ -22,9 +19,14 @@ pages:
- 'How to use the validation in your UI': 'docs/validation.md'
- 'Gulp command': 'docs/gulpCommand.md'
- 'Using Postman as a CRUD': 'docs/using-postman-as-a-crud.md'
- 'Known Issues': 'docs/knownIssues.md'
- 'KazooCon': 'docs/kazoocon.md'
- 'Test Plan': 'docs/testPlan.md'
- 'Summary': 'docs/summary.md'
- 'Monster Helpers':
- 'monster':
- 'Intro': 'docs/monster.md'
- 'docs/monster/getTemplate().md'
- 'docs/monster/parallel().md'
- 'docs/monster/pub().md'
- 'docs/monster/request().md'
Expand All @@ -33,7 +35,6 @@ pages:
- 'docs/monster/waterfall().md'
- 'monster.ui':
- 'Intro': 'docs/monster/ui.md'
- 'docs/monster/ui/table.md'
- 'docs/monster/ui/alert().md'
- 'docs/monster/ui/codecSelector().md'
- 'docs/monster/ui/confirm().md'
Expand All @@ -43,6 +44,7 @@ pages:
- 'docs/monster/ui/getFormData().md'
- 'docs/monster/ui/highlight().md'
- 'docs/monster/ui/insertTemplate().md'
- 'docs/monster/ui/loadTab().md'
- 'docs/monster/ui/mask().md'
- 'docs/monster/ui/protectField().md'
- 'docs/monster/ui/renderJSON().md'
Expand All @@ -55,6 +57,8 @@ pages:
- 'docs/monster/ui/wysiwyg().md'
- 'monster.util':
- 'Intro': 'docs/monster/util.md'
- 'docs/monster/util/canAddExternalNumbers().md'
- 'docs/monster/util/canImpersonate().md'
- 'docs/monster/util/dateToGregorian().md'
- 'docs/monster/util/formatPhoneNumber().md'
- 'docs/monster/util/formatPrice().md'
Expand All @@ -67,14 +71,18 @@ pages:
- 'docs/monster/util/isAdmin().md'
- 'docs/monster/util/isLoggedIn().md'
- 'docs/monster/util/isMasquerading().md'
- 'docs/monster/util/isReseller().md'
- 'docs/monster/util/isSuperDuper().md'
- 'docs/monster/util/isWhitelabeling().md'
- 'docs/monster/util/protectSensitivePhoneNumbers().md'
- 'docs/monster/util/randomString().md'
- 'docs/monster/util/sort().md'
- 'docs/monster/util/toFriendlyDate().md'
- 'docs/monster/util/unformatPhoneNumber().md'
- 'Data Flags':
- 'Data Flags':
- 'Intro': 'docs/monster/util/dataFlags.md'
- 'add()': 'docs/monster/util/dataFlags/add().md'
- 'destroy()': 'docs/monster/util/dataFlags/destroy().md'
- 'get()': 'docs/monster/util/dataFlags/get().md'
- 'get()': 'docs/monster/util/dataFlags/get().md'
- 'skeleton':
- 'docs/skeleton/method().md'
- 'docs/skeleton/object.md'
33 changes: 33 additions & 0 deletions scripts/reconcile_docs_to_index.bash
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
46 changes: 46 additions & 0 deletions scripts/validate_mkdocs.py
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)

0 comments on commit 7031e32

Please sign in to comment.