diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fdb496c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +scripts/build +scripts/nodesjs/build +node_modules +_site diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..222ad98 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +# This is the configuration for Travis CI, a free github-integrated service that runs this script for each pull request (if configured) + +# Be nice to travis, allow docker builds, must not use sudo below +sudo: false + +# provides gcc, clang, make, scons, cmake +language: c++ + +# alternatives: gcc, clang, or both (as yaml list) +compiler: clang + +install: + - + +script: + - cd scripts; make -k + - cd .. + +## find lines with tabs +# - rm -f CppCoreGuidelines.md.tabs +# - cat CppCoreGuidelines.md | nl -ba | sed -s 's/\(^[^\t]*\)\t/\1--/g' | grep $'\t' | sed -s 's/\t/\*\*\*\*/g' > CppCoreGuidelines.md.tabs +# - if [[ -s CppCoreGuidelines.md.tabs ]]; then echo 'Tabs found'; cat CppCoreGuidelines.md.tabs; false; fi; + +## check references unique + - rm -f CppCoreGuidelines.md.uniq + - grep -oP '(?<= CppCoreGuidelines.md.uniq + - if [[ -s CppCoreGuidelines.md.uniq ]]; then echo 'Found duplicate anchors:'; cat CppCoreGuidelines.md.uniq; false; fi; + + +notifications: + email: false diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..085711b --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,65 @@ +# This Makefile is supposed to run on the Travis CI server and also locally +# it assumes the nodejs package managaer npm is installed + +# make magic not needed +MAKEFLAGS += --no-builtin-rules +.SUFFIXES: + +BUILD_DIR=build +SOURCEFILE = CppCoreGuidelines.md +SOURCEPATH = ../$(SOURCEFILE) + +.PHONY: default +default: all + +.PHONY: all +all: \ +check-markdown \ +check-references + + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +#### clean: remove all files generated by the productive rules +.PHONY: clean +clean: + rm -rf $(BUILD_DIR) + +#### distclean: remove all helper executables that may be downloaded by the Makefile +.PHONY: distclean +distclean: + rm -rf ./nodejs/node_modules + + +#### check markdown + +## run remark markdown checker based on configuration in .remarkrc +.PHONY: check-markdown +check-markdown: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile +## run remark, paste output to temporary file + cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q --config-path ./remark/.remarkrc 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed --frail + +## show a diff with changes remark suggests +.PHONY: show-diff +show-diff: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile + cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q --config-path ./remark/.remarkrc 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed +## compare temporary file to original, error and fail with message if differences exist + diff $(SOURCEPATH) $(BUILD_DIR)/$(SOURCEFILE).fixed -u3 || \ + (echo "Error: remark found bad markdown syntax, see output above" && false) + + +.PHONY: check-references +check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile +## check references unique + rm $(BUILD_DIR)/$(SOURCEFILE).uniq + grep -oP '(?<= $(BUILD_DIR)/$(SOURCEFILE).uniq +## check if output has data + if [ -s "build/CppCoreGuidelines.md.uniq" ]; then echo 'Found duplicate anchors:'; cat $(BUILD_DIR)/$(SOURCEFILE).uniq; false; fi + + +#### install npm modules +# install/update npm dependencies defined in file package.json +# requires npm (nodejs package manager) +nodejs/node_modules/%: nodejs/package.json + @cd nodejs; npm install diff --git a/scripts/nodejs/package.json b/scripts/nodejs/package.json new file mode 100644 index 0000000..2b728e8 --- /dev/null +++ b/scripts/nodejs/package.json @@ -0,0 +1,12 @@ +{ + "name": "CppCoreGuidelinesCheck", + "version": "0.0.0", + "description": "CppCoreGuidelines Check", + "private": true, + "dependencies": { + "remark": "^4.2.0", + "remark-lint": "^3.2.0", + "remark-lint-sentence-newline": "^2.0.0", + "remark-validate-links": "^3.0.0" + } +} diff --git a/scripts/nodejs/remark/.remarkrc b/scripts/nodejs/remark/.remarkrc new file mode 100644 index 0000000..48e13f4 --- /dev/null +++ b/scripts/nodejs/remark/.remarkrc @@ -0,0 +1,31 @@ +{ +"plugins": { + "remark-lint": { + "unordered-list-marker-style": "consistent", + "list-item-bullet-indent": false, + "list-item-indent": false, + "list-item-spacing": false, + "no-html": false, + "maximum-line-length": false, + "no-file-name-mixed-case": false, + "heading-increment": false, + "no-multiple-toplevel-headings": false, + "no-consecutive-blank-lines": false, + "maximum-line-length": 9000, + "maximum-heading-length": 300, + "no-heading-punctuation": false, + "no-duplicate-headings": false, + "emphasis-marker": "*", + "no-tabs": false, + "blockquote-indentation": false, + "strong-marker": "*" + } + }, + "settings": { + "bullet": "*", + "listItemIndent": "1", + "strong": "*", + "emphasis": "*" + } + +}