diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..242feebce --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/docs/mkdocs/mkdocs.yml b/docs/mkdocs/mkdocs.yml index 2fda8748f..368ca6b71 100644 --- a/docs/mkdocs/mkdocs.yml +++ b/docs/mkdocs/mkdocs.yml @@ -1,7 +1,4 @@ site_name: UI Development -theme_dir: 2600Hz_theme -pages: -- 'index.md' pages: - 'index.md' @@ -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' @@ -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' @@ -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' @@ -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' @@ -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' \ No newline at end of file + - 'get()': 'docs/monster/util/dataFlags/get().md' + - 'skeleton': + - 'docs/skeleton/method().md' + - 'docs/skeleton/object.md' diff --git a/scripts/reconcile_docs_to_index.bash b/scripts/reconcile_docs_to_index.bash new file mode 100755 index 000000000..a0ebf1a79 --- /dev/null +++ b/scripts/reconcile_docs_to_index.bash @@ -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 diff --git a/scripts/validate_mkdocs.py b/scripts/validate_mkdocs.py new file mode 100755 index 000000000..d935bf153 --- /dev/null +++ b/scripts/validate_mkdocs.py @@ -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)