mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #705 from tkruse/fix-spellchecks
Fix markdown checks and spell checks
This commit is contained in:
commit
66c15ba47c
|
@ -37,16 +37,17 @@ distclean:
|
||||||
|
|
||||||
#### check markdown
|
#### check markdown
|
||||||
|
|
||||||
## run remark markdown checker based on configuration in package.json
|
## run remark markdown checker based on configuration in .remarkrc
|
||||||
.PHONY: check-markdown
|
.PHONY: check-markdown
|
||||||
check-markdown: nodejs/node_modules/remark nodejs/package.json $(SOURCEPATH) $(BUILD_DIR) Makefile
|
check-markdown: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
echo '##################### Markdown check ##################'
|
||||||
## run remark, paste output to temporary file
|
## run remark, paste output to temporary file
|
||||||
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed --frail
|
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
|
## show a diff with changes remark suggests
|
||||||
.PHONY: show-diff
|
.PHONY: show-diff
|
||||||
show-diff: nodejs/node_modules/remark nodejs/package.json $(SOURCEPATH) $(BUILD_DIR) Makefile
|
show-diff: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed
|
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
|
## compare temporary file to original, error and fail with message if differences exist
|
||||||
diff $(SOURCEPATH) $(BUILD_DIR)/$(SOURCEFILE).fixed -u3 || \
|
diff $(SOURCEPATH) $(BUILD_DIR)/$(SOURCEFILE).fixed -u3 || \
|
||||||
(echo "Error: remark found bad markdown syntax, see output above" && false)
|
(echo "Error: remark found bad markdown syntax, see output above" && false)
|
||||||
|
@ -54,6 +55,7 @@ show-diff: nodejs/node_modules/remark nodejs/package.json $(SOURCEPATH) $(BUILD_
|
||||||
|
|
||||||
.PHONY: check-references
|
.PHONY: check-references
|
||||||
check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
@echo '##################### References check ##################'
|
||||||
## check references unique
|
## check references unique
|
||||||
@rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq
|
@rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq
|
||||||
@grep -oP '(?<=<a name=")[^\"]+' $(SOURCEPATH) | sort | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq
|
@grep -oP '(?<=<a name=")[^\"]+' $(SOURCEPATH) | sort | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq
|
||||||
|
@ -62,6 +64,7 @@ check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
|
||||||
.PHONY: check-notabs
|
.PHONY: check-notabs
|
||||||
check-notabs: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
check-notabs: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
@echo '##################### Tabs check ##################'
|
||||||
# find lines with tabs
|
# find lines with tabs
|
||||||
# old file still might be around
|
# old file still might be around
|
||||||
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs
|
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs
|
||||||
|
@ -71,6 +74,7 @@ check-notabs: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
|
||||||
.PHONY: check-badchars
|
.PHONY: check-badchars
|
||||||
check-badchars: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
check-badchars: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
@echo '##################### Bad chars check ##################'
|
||||||
# find lines with tabs
|
# find lines with tabs
|
||||||
# old file still might be around
|
# old file still might be around
|
||||||
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars
|
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars
|
||||||
|
@ -81,8 +85,9 @@ check-badchars: $(SOURCEPATH) $(BUILD_DIR) Makefile
|
||||||
|
|
||||||
.PHONY: hunspell-check
|
.PHONY: hunspell-check
|
||||||
hunspell-check: $(BUILD_DIR)/plain-nohtml.txt
|
hunspell-check: $(BUILD_DIR)/plain-nohtml.txt
|
||||||
|
@echo '##################### Spell check ##################'
|
||||||
hunspell -p hunspell/isocpp.dic -u < build/plain-nohtml.txt > $(BUILD_DIR)/hunspell-report.txt
|
hunspell -p hunspell/isocpp.dic -u < build/plain-nohtml.txt > $(BUILD_DIR)/hunspell-report.txt
|
||||||
if [ -s $(BUILD_DIR)/hunspell-report.txt ]; then echo 'Warning: Spellcheck failed, fix words or add to dictionary:'; cat $(BUILD_DIR)/hunspell-report.txt; false; fi;
|
@if [ -s $(BUILD_DIR)/hunspell-report.txt ]; then echo 'Warning: Spellcheck failed, fix words or add to dictionary:'; cat $(BUILD_DIR)/hunspell-report.txt; false; fi;
|
||||||
|
|
||||||
# only list words that are not in dict
|
# only list words that are not in dict
|
||||||
# to include all add them to bottom of hunspell/isocpp.dict, and run
|
# to include all add them to bottom of hunspell/isocpp.dict, and run
|
||||||
|
@ -95,6 +100,7 @@ hunspell-list: $(BUILD_DIR)/plain.txt
|
||||||
|
|
||||||
.PHONY: cpplint-all
|
.PHONY: cpplint-all
|
||||||
cpplint-all: $(BUILD_DIR)/codeblocks $(BUILD_DIR)/Makefile python/Makefile.in
|
cpplint-all: $(BUILD_DIR)/codeblocks $(BUILD_DIR)/Makefile python/Makefile.in
|
||||||
|
@echo '##################### C++ Style check ##################'
|
||||||
cd $(BUILD_DIR)/codeblocks; $(MAKE) cpplint-all -k
|
cd $(BUILD_DIR)/codeblocks; $(MAKE) cpplint-all -k
|
||||||
|
|
||||||
#### generic makefile for sourceblocks (need to be evaluated after c++ file generation)
|
#### generic makefile for sourceblocks (need to be evaluated after c++ file generation)
|
||||||
|
|
|
@ -7,38 +7,6 @@
|
||||||
"remark": "^4.2.2",
|
"remark": "^4.2.2",
|
||||||
"remark-lint": "^4.0.2",
|
"remark-lint": "^4.0.2",
|
||||||
"remark-lint-sentence-newline": "^2.0.0",
|
"remark-lint-sentence-newline": "^2.0.0",
|
||||||
"remark-validate-links": "^4.1.0",
|
"remark-validate-links": "^4.1.0"
|
||||||
"remark-lint-are-links-valid": "^1.0.2"
|
|
||||||
},
|
|
||||||
"remarkConfig": {
|
|
||||||
"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": "*",
|
|
||||||
"external": ["remark-lint-are-links-valid"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"settings": {
|
|
||||||
"bullet": "*",
|
|
||||||
"listItemIndent": "1",
|
|
||||||
"strong": "*",
|
|
||||||
"emphasis": "*"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
scripts/nodejs/remark/.remarkrc
Normal file
31
scripts/nodejs/remark/.remarkrc
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"presets": ["lint-recommended", "lint-consistent"],
|
||||||
|
"plugins": {
|
||||||
|
"remark-lint": {
|
||||||
|
"unordered-list-marker-style": "consistent",
|
||||||
|
"list-item-bullet-indent": true,
|
||||||
|
"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": true,
|
||||||
|
"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": true,
|
||||||
|
"blockquote-indentation": false,
|
||||||
|
"strong-marker": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"bullet": "*",
|
||||||
|
"listItemIndent": "1",
|
||||||
|
"strong": "*",
|
||||||
|
"emphasis": "*"
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,6 +72,8 @@ def main():
|
||||||
sline = stripped(line)
|
sline = stripped(line)
|
||||||
text_filehandle.write(sline)
|
text_filehandle.write(sline)
|
||||||
|
|
||||||
|
assert line_length(args.sourcefile) == line_length(args.targetfile)
|
||||||
|
|
||||||
|
|
||||||
def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, codedir, name, index, indent_depth):
|
def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, codedir, name, index, indent_depth):
|
||||||
fenced = (line.strip() == '```')
|
fenced = (line.strip() == '```')
|
||||||
|
@ -91,16 +93,17 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
|
||||||
comment_idx = line.find('//')
|
comment_idx = line.find('//')
|
||||||
no_comment_line = line
|
no_comment_line = line
|
||||||
if comment_idx >= 0:
|
if comment_idx >= 0:
|
||||||
no_comment_line = line[:comment_idx]
|
no_comment_line = line[:comment_idx].strip()
|
||||||
text_filehandle.write(line[comment_idx + 2:])
|
text_filehandle.write(line[comment_idx + 2:])
|
||||||
|
else:
|
||||||
|
# write empty line so line numbers stay stable
|
||||||
|
text_filehandle.write('\n')
|
||||||
|
|
||||||
if (not has_actual_code
|
if (not has_actual_code
|
||||||
and not line.strip().startswith('//')
|
and not line.strip().startswith('//')
|
||||||
and not line.strip().startswith('???')
|
and not line.strip().startswith('???')
|
||||||
and not line.strip() == ''):
|
and not line.strip() == ''):
|
||||||
has_actual_code = True
|
has_actual_code = True
|
||||||
else:
|
|
||||||
# write empty line so line numbers stay stable
|
|
||||||
text_filehandle.write('\n')
|
|
||||||
|
|
||||||
if (not line.strip() == '```'):
|
if (not line.strip() == '```'):
|
||||||
if ('???' == no_comment_line or '...' == no_comment_line):
|
if ('???' == no_comment_line or '...' == no_comment_line):
|
||||||
|
@ -171,5 +174,8 @@ def get_marker(line):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def line_length(filename):
|
||||||
|
return sum(1 for line in open(filename))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user