-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the module context rule as it doesn't highlight anything in …
…VS Code. Using tengo you can highlight first line.
- Loading branch information
Showing
3 changed files
with
62 additions
and
6 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
31 changes: 26 additions & 5 deletions
31
.vale/styles/OpenShiftAsciiDoc/ModuleContainsContentType.yml
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 |
---|---|---|
@@ -1,8 +1,29 @@ | ||
--- | ||
extends: occurrence | ||
scope: raw | ||
extends: script | ||
message: "Module is missing the \":_mod-docs-content-type:\" variable." | ||
level: error | ||
link: https://github.com/openshift/openshift-docs/blob/main/contributing_to_docs/doc_guidelines.adoc#module-file-metadata | ||
message: "Module is missing the \"_mod-docs-content-type\" variable." | ||
min: 1 | ||
token: '(?<!\/\/):_mod-docs-content-type:(\s)?(CONCEPT|PROCEDURE|REFERENCE|ASSEMBLY|SNIPPET)' | ||
scope: raw | ||
script: | | ||
text := import("text") | ||
matches := [] | ||
//trim extra whitespace | ||
scope = text.trim_space(scope) | ||
//add a newline, it might be missing | ||
scope += "\n" | ||
context_regex := ":_mod-docs-content-type: (CONCEPT|SNIPPET|ASSEMBLY|PROCEDURE|REFERENCE)" | ||
match := false | ||
//Check if context declaration is on any line | ||
for line in text.split(scope, "\n") { | ||
if text.re_match(context_regex, line){ | ||
match = true | ||
} | ||
} | ||
//Highlight first line if context declaration not found in file | ||
if match == false { | ||
matches = append(matches, {begin: 1, end: 10}) | ||
} |
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,36 @@ | ||
/* | ||
Tengo Language | ||
Checks that lines are not hard-wrapped. | ||
$ tengo HardWrappedLines.tengo <asciidoc_file_to_validate> | ||
*/ | ||
|
||
fmt := import("fmt") | ||
os := import("os") | ||
text := import("text") | ||
|
||
input := os.args() | ||
scope := os.read_file(input[2]) | ||
matches := [] | ||
|
||
//trim extra whitespace | ||
scope = text.trim_space(scope) | ||
//add a newline, it might be missing | ||
scope += "\n" | ||
|
||
context_regex := ":_content-type: (CONCEPT|SNIPPET|ASSEMBLY|PROCEDURE|REFERENCE)" | ||
match := false | ||
|
||
//Check if context declaration is on any line | ||
for line in text.split(scope, "\n") { | ||
if text.re_match(context_regex, line){ | ||
match = true | ||
fmt.println("Found content-type declaration") | ||
} | ||
} | ||
|
||
//Highlight first line if context declaration not found in file | ||
if match == false { | ||
matches = append(matches, {begin: 1, end: 10}) | ||
fmt.println("Did not find content-type declaration") | ||
fmt.println(matches) | ||
} |