diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..aebab5a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +--- +# +# Copyright (c) 2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +name: Release +on: + push: + branches: + - main +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Create AsciiDoc ruleset release + run: | + cd .vale/styles + echo $GITHUB_RUN_NUMBER > version.txt + zip -r AsciiDoc.zip AsciiDoc + zip -r OpenShiftAsciiDoc.zip OpenShiftAsciiDoc + gh release create v$GITHUB_RUN_NUMBER 'AsciiDoc.zip' 'OpenShiftAsciiDoc.zip' + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/validate-on-pull.yml b/.github/workflows/validate-on-pull.yml new file mode 100644 index 0000000..d204482 --- /dev/null +++ b/.github/workflows/validate-on-pull.yml @@ -0,0 +1,19 @@ +--- +name: Verify Vale test fixtures +on: + - pull_request +jobs: + validate-rules: + name: Validate rules + runs-on: ubuntu-latest + #antora-for-modular-docs:main includes vale + container: quay.io/antoraformodulardocs/antora-for-modular-docs:main + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 # enable git diff and building many branches + - name: Validate Vale rules + id: validate-rules + run: scripts/validate-vale-rules.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1001a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/** diff --git a/.vale.ini b/.vale.ini new file mode 100644 index 0000000..ce205df --- /dev/null +++ b/.vale.ini @@ -0,0 +1,11 @@ +StylesPath = ../.vale/styles + +MinAlertLevel = suggestion + +Packages = https://github.com/rohennes/ocp-rules/releases/latest/download/AsciiDoc.zip + +#Ignore block comments in AsciiDoc source +TokenIgnores = (\/\/\/\/\n(.*\n)*\/\/\/\/\n) + +[[!.]*.adoc] +BasedOnStyles = RedHat, AsciiDoc \ No newline at end of file diff --git a/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/.vale.ini b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/.vale.ini new file mode 100644 index 0000000..5822dc7 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ClosedAttributeBlocks` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ClosedAttributeBlocks = YES diff --git a/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testinvalid.adoc new file mode 100644 index 0000000..f22a517 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testinvalid.adoc @@ -0,0 +1,9 @@ +//vale-fixture +:_content-type: ASSEMBLY +[id="rosa-getting-started += Comprehensive guide to getting started with {product-title} + +//vale-fixture +:_content-type: ASSEMBLY +[id="rosa-getting-started_{context} += Another guide to getting started diff --git a/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testvalid.adoc b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testvalid.adoc new file mode 100644 index 0000000..a39e3d2 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedAttributeBlocks/testvalid.adoc @@ -0,0 +1,35 @@ +//vale-fixture +:_content-type: ASSEMBLY +[id="rosa-getting-started_{context}"] += Comprehensive guide to getting started with {product-title} + +//vale-fixture +.Example output +[source,terminal] +---- +{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"up","endpoint":"web","instance":"10.129.0.46:8080","job":"prometheus-example-app","namespace":"ns1","pod":"prometheus-example-app-68d47c4fb6-jztp2","service":"prometheus-example-app"},"value":[1591881154.748,"1"]}]}} +---- + +//vale-fixture +[source,terminal] +---- +$ oc adm must-gather +[must-gather ] OUT Using must-gather plugin-in image: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:125f183d13601537ff15b3239df95d47f0a604da2847b561151fedd699f5e3a5 +[must-gather ] OUT namespace/openshift-must-gather-xm4wq created +[must-gather ] OUT clusterrolebinding.rbac.authorization.k8s.io/must-gather-2bd8x created +[must-gather ] OUT pod for plug-in image quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:125f183d13601537ff15b3239df95d47f0a604da2847b561151fedd699f5e3a5 created +---- + +//vale-fixture +.Example API response +[source,json] +---- +[ + { + "id": "ca11ab76-86f9-428c-8d3a-666c24e34d32", + "endpointUri": "http://localhost:9089/api/ocloudNotifications/v1/dummy", + "uriLocation": "http://localhost:8089/api/ocloudNotifications/v1/subscriptions/ca11ab76-86f9-428c-8d3a-666c24e34d32", + "resource": "/cluster/node/openshift-worker-0.openshift.example.com/redfish/event" + } +] +---- diff --git a/.vale/fixtures/AsciiDoc/ClosedIdQuotes/.vale.ini b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/.vale.ini new file mode 100644 index 0000000..8d4d742 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ClosedIdQuotes` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ClosedIdQuotes = YES diff --git a/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testinvalid.adoc new file mode 100644 index 0000000..7d6957f --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testinvalid.adoc @@ -0,0 +1,7 @@ +//vale-fixture +[id="rosa-getting-started_{context}] += Comprehensive guide to getting started with {product-title} + +//vale-fixture +[id="rosa-getting-started] += Another guide to getting started diff --git a/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testvalid.adoc b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testvalid.adoc new file mode 100644 index 0000000..b342f75 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ClosedIdQuotes/testvalid.adoc @@ -0,0 +1,4 @@ +//vale-fixture +:_content-type: ASSEMBLY +[id="rosa-getting-started_{context}"] += Comprehensive guide to getting started with {product-title} diff --git a/.vale/fixtures/AsciiDoc/ImageContainsAltText/.vale.ini b/.vale/fixtures/AsciiDoc/ImageContainsAltText/.vale.ini new file mode 100644 index 0000000..7b0ba38 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ImageContainsAltText/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `XrefContainsAnchorID` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ImageContainsAltText = YES diff --git a/.vale/fixtures/AsciiDoc/ImageContainsAltText/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ImageContainsAltText/testinvalid.adoc new file mode 100644 index 0000000..5eb467f --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ImageContainsAltText/testinvalid.adoc @@ -0,0 +1,2 @@ +//vale-fixture +image::my-image-name.png[] \ No newline at end of file diff --git a/.vale/fixtures/AsciiDoc/ImageContainsAltText/testvalid.adoc b/.vale/fixtures/AsciiDoc/ImageContainsAltText/testvalid.adoc new file mode 100644 index 0000000..95298ba --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ImageContainsAltText/testvalid.adoc @@ -0,0 +1,2 @@ +//Correct usage of alt text in image tags +image::my-image-name.png[my-image-alt-text] \ No newline at end of file diff --git a/.vale/fixtures/AsciiDoc/MatchingDotCallouts/.vale.ini b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/.vale.ini new file mode 100644 index 0000000..5fc7ffd --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `SequentialNumberedCallouts` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.MatchingDotCallouts = YES diff --git a/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testinvalid.adoc b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testinvalid.adoc new file mode 100644 index 0000000..4efd682 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testinvalid.adoc @@ -0,0 +1,25 @@ +//vale-fixture +[source,ruby] +---- +get '/hi' do <.> +get '/hi' do <.> +get '/hi' do<.> <.> <.> +---- +<.> first callout +<.> second callout +<.> third callout +<.> fourth callout +<.> fifth callout +<.> sixth callout + +//vale-fixture +[source,ruby] +---- +get '/hi' do <.> +get '/hi' do <.> +get '/hi' do <.> +---- +<.> first callout, second block +<.> second callout, second block +<.> third callout, second block +<.> fourth callout, second block diff --git a/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testvalid.adoc b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testvalid.adoc new file mode 100644 index 0000000..8d4493c --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingDotCallouts/testvalid.adoc @@ -0,0 +1,12 @@ +//vale-fixture +[source,ruby] +---- +require 'sinatra' <.> + +get '/hi' do <.> + "Hello World!" <.> +end +---- +<.> Library import +<.> URL mapping +<.> Response block diff --git a/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/.vale.ini b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/.vale.ini new file mode 100644 index 0000000..99a9f13 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `SequentialNumberedCallouts` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.MatchingNumberedCallouts = YES diff --git a/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testinvalid.adoc b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testinvalid.adoc new file mode 100644 index 0000000..0abadf8 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testinvalid.adoc @@ -0,0 +1,20 @@ +//vale-fixture +[source,ruby] +---- +require 'frank' <1> +get '/hihi'<2><3> +---- +<1> text +<2> More text +<3> More text again +<4> Again, more text + +//vale-fixture +[source,ruby] +---- +require 'frankie' <1> +get '/hihihi' <2> +---- +<1> text! +<2> More text! +<3> More text again! diff --git a/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testvalid.adoc b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testvalid.adoc new file mode 100644 index 0000000..419c552 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/MatchingNumberedCallouts/testvalid.adoc @@ -0,0 +1,26 @@ +//vale-fixture +[source,ruby] +---- +require 'sinatra' <1> + +get '/hi' do <2> <3> + "Hello World!" +end +---- +<1> Library import +<2> URL mapping +<3> Response block + +//vale-fixture +[source,ruby] +---- +require 'sinatra' \\//<1> + +get '/hi' do <2><3> + "Hello World!"<4> +end +---- +<1> Library import +<2> URL mapping +<3> Response block +<4> Hi \ No newline at end of file diff --git a/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/.vale.ini b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/.vale.ini new file mode 100644 index 0000000..59cf66b --- /dev/null +++ b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `SequentialNumberedCallouts` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.SequentialNumberedCallouts = YES diff --git a/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testinvalid.adoc b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testinvalid.adoc new file mode 100644 index 0000000..6afd7f4 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testinvalid.adoc @@ -0,0 +1,21 @@ +[source,ruby] +---- +require 'sinatra' <1> +get '/hi' do <2> +require 'sinatra' <3> +get '/hi' do <4> +hi there <5> +goop <6> +require 'sinatra' + +get '/hi' do <7> <8> + "Hello World!" +---- +//vale-fixture +<1> text +<2> More text +<3> More text again +<5> Some text +<6> Again, some text +<7> Moar text +<8> Again, some more text diff --git a/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testvalid.adoc b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testvalid.adoc new file mode 100644 index 0000000..abb0837 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/SequentialNumberedCallouts/testvalid.adoc @@ -0,0 +1,25 @@ +//vale-fixture +[source,ruby] +---- +require 'sinatra' <1> + +get '/hi' do <2> <3> + "Hello World!" +end +---- +<1> Library import +<2> URL mapping +<3> Response block + +//vale-fixture +[source,ruby] +---- +require 'sinatra' <1> + +get '/hi' do <1> + "Hello World!" +end +key: value <2> +---- +<1> Library import +<2> URL mapping diff --git a/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/.vale.ini b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/.vale.ini new file mode 100644 index 0000000..1d27dec --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ValidAdmonitionBlocks` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ValidAdmonitionBlocks = YES diff --git a/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testinvalid.adoc new file mode 100644 index 0000000..a1bedcd --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testinvalid.adoc @@ -0,0 +1,18 @@ +//vale-fixture +Here is a Admonition block: + +[IMPORTANT] +.Feeding the Werewolves +==== +While werewolves are hardy community members, keep in mind the following dietary concerns: + +. They are allergic to cinnamon. +. More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens. +. Celery makes them sad. + +More text + +[NOTE] +==== +Hello +==== diff --git a/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testvalid.adoc b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testvalid.adoc new file mode 100644 index 0000000..024577a --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidAdmonitionBlocks/testvalid.adoc @@ -0,0 +1,12 @@ +//vale-fixture +Here is a Admonition block: + +[IMPORTANT] +.Feeding the Werewolves +==== +While werewolves are hardy community members, keep in mind the following dietary concerns: + +. They are allergic to cinnamon. +. More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens. +. Celery makes them sad. +==== diff --git a/.vale/fixtures/AsciiDoc/ValidCodeBlocks/.vale.ini b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/.vale.ini new file mode 100644 index 0000000..c244f78 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ValidConditions` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ValidCodeBlocks = YES diff --git a/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testinvalid.adoc new file mode 100644 index 0000000..d3827f8 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testinvalid.adoc @@ -0,0 +1,33 @@ +//vale-fixture +Here is a code block: + +[source,terminal] +---- +$ pwd +---- + +Here is a another code block: + +[source,terminal] +---- +$ pwd +---- + +Here is a code block: + +[source,yaml] +---- +--- +apiVersion: 4.11 + +Some text. + +Here is a code block: + +[subs="+quotes",options="nowrap",role="white-space-pre"] +---- +--- +apiVersion: 4.11 +---- + +Some text. diff --git a/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testvalid.adoc b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testvalid.adoc new file mode 100644 index 0000000..513732a --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidCodeBlocks/testvalid.adoc @@ -0,0 +1,37 @@ +//vale-fixture +Here is a code block: + +[source,terminal] +---- +$ pwd +---- + +Here is a another code block: + +[source,java] +---- +$ pwd +---- + +Here is yet another code block: + +[source,python] +---- +$ pwd +---- + +[source,yaml] +----- +$ pwd +----- + + +Some text. + +//vale-fixture +Here is a final code block: + +[source,terminal] +---- +$ pwd +---- diff --git a/.vale/fixtures/AsciiDoc/ValidConditions/.vale.ini b/.vale/fixtures/AsciiDoc/ValidConditions/.vale.ini new file mode 100644 index 0000000..e29e99a --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidConditions/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ValidConditions` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ValidConditions = YES diff --git a/.vale/fixtures/AsciiDoc/ValidConditions/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ValidConditions/testinvalid.adoc new file mode 100644 index 0000000..a10434c --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidConditions/testinvalid.adoc @@ -0,0 +1,33 @@ +//vale-fixture +ifdef::env-github[] +This content is for GitHub only. + +//vale-fixture +ifndef::env-github[] +This content is for GitHub only. + +So much content in this section, I'd get confused reading the source without the closing `ifdef` directive. + +//vale-fixture +ifdef::revnumber[] +This document has a version number of {revnumber}. + +//vale-fixture +ifeval::[2 > 1] +Some text! + +//vale-fixture +ifeval::["{docname}{outfilesuffix}" == "main.html"] +Some text! + +//vale-fixture +ifeval::["{docname}{outfilesuffix}" == "main.html"] +Some text! + +//vale-fixture +ifeval::["{docname}{outfilesuffix}" == "main.html"] +Some text! + +//vale-fixture +ifeval::[derp] +Some text! diff --git a/.vale/fixtures/AsciiDoc/ValidConditions/testvalid.adoc b/.vale/fixtures/AsciiDoc/ValidConditions/testvalid.adoc new file mode 100644 index 0000000..3bf5d6b --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidConditions/testvalid.adoc @@ -0,0 +1,42 @@ +//vale-fixture +ifdef::env-github[] +This content is for GitHub only. +endif::env-github[] + +//vale-fixture +ifndef::env-github[] +This content is for GitHub only. + +So much content in this section, I'd get confused. +endif::[] + +//vale-fixture +ifdef::revnumber[] +This document has a version number of {revnumber}. +endif::[] + +//vale-fixture - doesn't work +//ifndef::profile-production,env-site[Not shown if profile-production or env-site is set.] + +//vale-fixture +ifndef::profile-staging+env-site[Not shown if profile-staging and env-site are set.] + +//vale-fixture +ifeval::[2 > 1] +Some text! +endif::[] + +//vale-fixture +ifeval::["{backend}" == "html5"] +Some text! +endif::[] + +//vale-fixture +ifeval::[{sectnumlevels} == 3] +Some text! +endif::[] + +//vale-fixture +ifeval::["{docname}{outfilesuffix}" == "main.html"] +Some text! +endif::[] diff --git a/.vale/fixtures/AsciiDoc/ValidTableBlocks/.vale.ini b/.vale/fixtures/AsciiDoc/ValidTableBlocks/.vale.ini new file mode 100644 index 0000000..1a65552 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidTableBlocks/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ValidConditions` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +AsciiDoc.ValidTableBlocks = YES diff --git a/.vale/fixtures/AsciiDoc/ValidTableBlocks/testinvalid.adoc b/.vale/fixtures/AsciiDoc/ValidTableBlocks/testinvalid.adoc new file mode 100644 index 0000000..3b1479e --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidTableBlocks/testinvalid.adoc @@ -0,0 +1,37 @@ +//vale-fixture +.Table one +[cols=3*,stripes=even] +|=== +|Header column 1 |Header column 2 |Header column 3 +|Cell 1, row 1 +|Cell 2, row 1 +|Cell 3, row 1 +Some text. +|=== + +.Table two +[options="header"] +|==== +|Column Title|Column Title +|content|content +|==== +This content goes on and on. + +Some text. + +.Table three +[options="header"] +|==== +|Column Title|Column Title|Column Title +|content|content|content +|==== + +Some text. + +.Table four +[options="header"] +|==== +|Column Title|Column Title|Column Title +|content|content|content + +Some text. diff --git a/.vale/fixtures/AsciiDoc/ValidTableBlocks/testvalid.adoc b/.vale/fixtures/AsciiDoc/ValidTableBlocks/testvalid.adoc new file mode 100644 index 0000000..e9e5724 --- /dev/null +++ b/.vale/fixtures/AsciiDoc/ValidTableBlocks/testvalid.adoc @@ -0,0 +1,58 @@ +//vale-fixture +.Table one +[options="header"] +|=== +|Header column 1 |Header column 2 |Header column 3 + +|Cell 1, row 1 +|Cell 2, row 1 +|Cell 3, row 1 +|=== + +Some text. + +//vale-fixture +.Table two +[options="header"] +|==== +|Column Title|Column Title +|content|content +This content goes on and on. +|==== + +Some text. + +//vale-fixture +[caption="test"] +.Table three +|======= +|A |B |C +|a |b |c +|1 |2 |3 +|======= + +Some text. + +//vale-fixture +.Table four +[options="header"] +|==== +|Column Title|Column Title|Column Title +|content|content|content +|==== + +Some text. + +//vale-fixture +.Table five +[cols=2*, width="40%", options="header"] +|==== +|Firefox +|Web Browser + +|Ruby +|Programming Language + +|TorqueBox +|Application Server +|==== diff --git a/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/.vale.ini new file mode 100644 index 0000000..4a215da --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `AdditionalResourcesHeadingHasRoleID` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.AdditionalResourcesHeadingHasRoleID = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testinvalid.adoc new file mode 100644 index 0000000..a83062f --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testinvalid.adoc @@ -0,0 +1,2 @@ +//vale-fixture +.Additional resources diff --git a/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testvalid.adoc new file mode 100644 index 0000000..c3b0d2b --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID/testvalid.adoc @@ -0,0 +1,2 @@ +[role="_additional-resources"] +.Additional resources diff --git a/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/.vale.ini new file mode 100644 index 0000000..f3a6da7 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `CheckDollarSymbolInTerminalBlock` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.CheckDollarSymbolInTerminalBlock = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testinvalid.adoc new file mode 100644 index 0000000..ab47e4c --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testinvalid.adoc @@ -0,0 +1,12 @@ +//vale-fixture +[source,bash] +---- + oc get my lunch +---- + +//vale-fixture +[source,terminal] +---- +oc get my lunch +---- + diff --git a/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testvalid.adoc new file mode 100644 index 0000000..0f8ee4b --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/CheckDollarSymbolInTerminalBlock/testvalid.adoc @@ -0,0 +1,93 @@ +[source,bash] +---- +$ oc get my lunch +---- + +[source,yaml] +---- +oc get my lunch +---- + +[source,terminal] +---- +$ oc get my lunch +---- + +[source,terminal] +---- +# oc get my lunch +---- + +.Example output +[source,terminal] +---- +Computer says no +---- + +.Sample output +[source,bash] +---- +Computer says no +---- + +.Example +[source,terminal] +---- +spec: + settings: + ProcTurboMode: Disabled<1> +---- + +[source,terminal] +---- +C:\> net user +---- + +. Change your root directory to the host: ++ +[source,terminal] +---- +sh-4.2# chroot /host +---- + +[source,terminal] +---- +. +├── CODEOWNERS +├── README.md +└── scripts + └── validate-vale-rules.sh +---- + +[source,terminal] +---- +├── CODEOWNERS +├── README.md +└── scripts + └── validate-vale-rules.sh +---- + +[source,terminal] +---- +[ansible@control-node]$ +---- + +[source,terminal] +---- +(undercloud)$ cd go/to/path +---- + +[source,terminal] +---- +(undercloud) [stack@director ~]$ cd go/to/path +---- + +[source,terminal] +---- +sh-4.2# chroot /host +---- + +[source,yaml] +---- +include::yaml/boundary-clock-ptp-config.yaml[] +---- \ No newline at end of file diff --git a/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/.vale.ini new file mode 100644 index 0000000..7926aff --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `IdHasContextVariable` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.IdHasContextVariable = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testinvalid.adoc new file mode 100644 index 0000000..10652a7 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testinvalid.adoc @@ -0,0 +1,5 @@ +//vale-fixture +[id="cli-basic-commands_"] + +//vale-fixture +[id="another-id-in-the-same-module-also-gets-flagged"] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testvalid.adoc new file mode 100644 index 0000000..8a36f1b --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/IdHasContextVariable/testvalid.adoc @@ -0,0 +1,3 @@ +:_content-type: REFERENCE +[id="cli-basic-commands_{context}"] += Basic CLI commands diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/.vale.ini new file mode 100644 index 0000000..7f26363 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ModuleContainsContentType` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.ModuleContainsContentType = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testinvalid.adoc new file mode 100644 index 0000000..b5148cb --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testinvalid.adoc @@ -0,0 +1,5 @@ +//vale-fixture +// Error only flagged from cmd line. If the content-type has the wrong test, or is missing entirely, the rule is triggered. +:_content-type: WRONG_TEXT +[id="cli-basic-commands_{context}"] += Basic CLI commands diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testvalid.adoc new file mode 100644 index 0000000..4a368d8 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsContentType/testvalid.adoc @@ -0,0 +1,15 @@ +:_content-type: REFERENCE +[id="cli-basic-commands_{context}"] += Basic CLI commands + +:_content-type: PROCEDURE +[id="cli-basic-commands_{context}"] + +:_content-type: CONCEPT +[id="cli-basic-commands_{context}"] + +:_content-type: ASSEMBLY +[id="cli-basic-commands_{context}"] + +:_content-type: SNIPPET +[id="cli-basic-commands_{context}"] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/.vale.ini new file mode 100644 index 0000000..dded176 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `ModuleContainsParentAssemblyComment` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.ModuleContainsParentAssemblyComment = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testinvalid.adoc new file mode 100644 index 0000000..7e1cbe0 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testinvalid.adoc @@ -0,0 +1,5 @@ +//vale-fixture +Here's some text. I have no commented lines in this file indicating the parent assembly. + + +This rule is only flagged when you run vale on this file from the cmd line. diff --git a/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testvalid.adoc new file mode 100644 index 0000000..fde11c8 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/ModuleContainsParentAssemblyComment/testvalid.adoc @@ -0,0 +1,4 @@ +//Module is included in... + +//This module is included... + diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/.vale.ini new file mode 100644 index 0000000..cb7dcd1 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `NoNestingInModules` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.NoNestingInModules = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testinvalid.adoc new file mode 100644 index 0000000..9df5c86 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testinvalid.adoc @@ -0,0 +1,5 @@ +//vale-fixture +include::modules/rosa-getting-started-deleting-a-cluster.adoc[leveloffset=+1] + +//vale-fixture +include::rosa-getting-started-deleting-a-cluster.adoc[leveloffset=+1] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testvalid.adoc new file mode 100644 index 0000000..78d2f5d --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoNestingInModules/testvalid.adoc @@ -0,0 +1,15 @@ +include::snippets/technology-preview.adoc[leveloffset=+0] + +include::https://raw.githubusercontent.com/openshift/managed-cluster-validating-webhooks/master/docs/webhooks.json[] + +include::yaml/ordinary-clock.yaml[leveloffset=+0] + +include::yaml/ordinary-clock.yml[leveloffset=+0] + +include::ordinary-clock.json[leveloffset=+0] + +include::ordinary-clock.txt[leveloffset=+0] + +include::ordinary-clock.md[leveloffset=+0] + +include::xml/path/ordinary-clock.xml[] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/.vale.ini new file mode 100644 index 0000000..e51b482 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `NoXrefInModules` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.NoXrefInModules = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testinvalid.adoc new file mode 100644 index 0000000..885b8fc --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testinvalid.adoc @@ -0,0 +1,2 @@ +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.adoc#rosa-getting-started[Getting started with {product-title}] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testvalid.adoc new file mode 100644 index 0000000..2a4fb8c --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/NoXrefInModules/testvalid.adoc @@ -0,0 +1 @@ +No xrefs here! diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/.vale.ini new file mode 100644 index 0000000..621bd27 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `XrefContainsAnchorID` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.XrefContainsAnchorID = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testinvalid.adoc new file mode 100644 index 0000000..5faba19 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testinvalid.adoc @@ -0,0 +1,8 @@ +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.adoc[Getting started with {product-title}] + +//vale-fixture +xref:../../rosa_getting_started/rosa-getting-started.adoc + +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.adoc[] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testvalid.adoc new file mode 100644 index 0000000..b128ebb --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsAnchorID/testvalid.adoc @@ -0,0 +1,3 @@ +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started[Getting started with {product-title}] + +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/.vale.ini new file mode 100644 index 0000000..33a9e53 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `XrefContainsHTML` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.XrefContainsHTML = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testinvalid.adoc new file mode 100644 index 0000000..9c78ea7 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testinvalid.adoc @@ -0,0 +1,8 @@ +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.html#getting-started[Getting started with {product-title}] + +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.html#getting-started + + + diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testvalid.adoc new file mode 100644 index 0000000..3453e76 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefContainsHTML/testvalid.adoc @@ -0,0 +1,6 @@ +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started[Getting started with {product-title}] + +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started + + + diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/.vale.ini b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/.vale.ini new file mode 100644 index 0000000..7f88295 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `XrefMustNotHaveNakedLabel` rule +StylesPath = ../../../styles +MinAlertLevel = suggestion +[*.adoc] +OpenShiftAsciiDoc.XrefMustNotHaveNakedLabel = YES diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testinvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testinvalid.adoc new file mode 100644 index 0000000..272e8f3 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testinvalid.adoc @@ -0,0 +1,2 @@ +//vale-fixture +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started[] diff --git a/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testvalid.adoc b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testvalid.adoc new file mode 100644 index 0000000..0f5a2a4 --- /dev/null +++ b/.vale/fixtures/OpenShiftAsciiDoc/XrefMustNotHaveNakedLabel/testvalid.adoc @@ -0,0 +1,6 @@ +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started[Getting started with {product-title}] + +xref:../rosa_getting_started/rosa-getting-started.adoc#getting-started[Getting started] + + + diff --git a/.vale/fixtures/RedHat/Localization/.vale.ini b/.vale/fixtures/RedHat/Localization/.vale.ini new file mode 100644 index 0000000..7ceb314 --- /dev/null +++ b/.vale/fixtures/RedHat/Localization/.vale.ini @@ -0,0 +1,5 @@ +; Vale configuration file to test the `Localization` rule +StylesPath = ../../../styles +MinAlertLevel = warning +[*.adoc] +RedHat.Localization = YES diff --git a/.vale/fixtures/RedHat/Localization/testinvalid.adoc b/.vale/fixtures/RedHat/Localization/testinvalid.adoc new file mode 100644 index 0000000..de92dde --- /dev/null +++ b/.vale/fixtures/RedHat/Localization/testinvalid.adoc @@ -0,0 +1,33 @@ +Once +Since +As +While +At once +May +Allow +Acronym +Will +Have + verb +etc +ie +eg +ex +via +vs +versus +et cetera +per se +vice versa +could +may +supposed to be +ought to be +Won’t +The following +The previous +This is +These are +Those are +Theirs +Hers +His \ No newline at end of file diff --git a/.vale/fixtures/RedHat/Localization/testvalid.adoc b/.vale/fixtures/RedHat/Localization/testvalid.adoc new file mode 100644 index 0000000..22a7dee --- /dev/null +++ b/.vale/fixtures/RedHat/Localization/testvalid.adoc @@ -0,0 +1,12 @@ +after +One time +Because +After +During +At the same time +Might +Enable +Abbreviation +Can +Cannot +Might diff --git a/.vale/styles/AsciiDoc/ClosedAttributeBlocks.yml b/.vale/styles/AsciiDoc/ClosedAttributeBlocks.yml new file mode 100644 index 0000000..471662b --- /dev/null +++ b/.vale/styles/AsciiDoc/ClosedAttributeBlocks.yml @@ -0,0 +1,7 @@ +--- +extends: existence +scope: raw +level: error +message: "Attribute block is not closed." +raw: + - '(?" + callout_regex := "^<(\\.)>" + + for line in text.split(scope, "\n") { + if text.re_match(codeblock_callout_regex, line) { + //restart for new listingblock + num_callouts = 0 + //account for lines with multiple callouts + num_callouts_in_line := text.count(line, "<.>") + if num_callouts_in_line > 1 { + num_codeblock_callouts = num_codeblock_callouts + num_callouts_in_line + } else { + num_codeblock_callouts++ + } + } + + if text.re_match(callout_regex, line) { + num_callouts++ + if num_callouts > num_codeblock_callouts { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + if num_callouts == num_codeblock_callouts { + num_callouts = 0 + num_codeblock_callouts = 0 + } + } + } diff --git a/.vale/styles/AsciiDoc/MatchingNumberedCallouts.yml b/.vale/styles/AsciiDoc/MatchingNumberedCallouts.yml new file mode 100644 index 0000000..f276ba9 --- /dev/null +++ b/.vale/styles/AsciiDoc/MatchingNumberedCallouts.yml @@ -0,0 +1,45 @@ +--- +extends: script +message: "Corresponding callout not found." +level: error +link: https://docs.asciidoctor.org/asciidoc/latest/verbatim/callouts/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + num_codeblock_callouts := 0 + num_callouts := 0 + codeblock_callout_regex := ".(<\\d+>)+" + callout_regex := "^<(\\d+)>" + + for line in text.split(scope, "\n") { + if text.re_match(codeblock_callout_regex, line) { + //restart for new listingblock + num_callouts = 0 + //account for lines with multiple callouts + for i := 1; i < len(line); i++ { + //text.count must be str, not regex + str := "<" + i + ">" + num_callouts_in_line := text.count(line, str) + num_codeblock_callouts += num_callouts_in_line + } + } + + if text.re_match(callout_regex, line) { + num_callouts++ + if num_callouts > num_codeblock_callouts { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + if num_callouts == num_codeblock_callouts { + num_callouts = 0 + num_codeblock_callouts = 0 + } + } + } diff --git a/.vale/styles/AsciiDoc/SequentialNumberedCallouts.yml b/.vale/styles/AsciiDoc/SequentialNumberedCallouts.yml new file mode 100644 index 0000000..90b07a4 --- /dev/null +++ b/.vale/styles/AsciiDoc/SequentialNumberedCallouts.yml @@ -0,0 +1,43 @@ +--- +extends: script +message: "Numbered callout does not follow sequentially." +level: warning +link: https://docs.asciidoctor.org/asciidoc/latest/verbatim/callouts/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + prev_num := 0 + callout_regex := "^<(\\d+)>" + listingblock_delim_regex := "^-{4,}$" + + for line in text.split(scope, "\n") { + //reset count if we hit a listing block delimiter + if text.re_match(listingblock_delim_regex, line) { + prev_num = 0 + } + + if text.re_match(callout_regex, line) { + callout := text.re_find("<(\\d+)>", line) + for key, value in callout { + //trim angle brackets from string + trimmed := callout[key][0]["text"] + trimmed = text.trim_prefix(trimmed, "<") + trimmed = text.trim_suffix(trimmed, ">") + //cast string > int + num := text.atoi(trimmed) + //start counting + if num != prev_num+1 { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + prev_num = num + } + } + } diff --git a/.vale/styles/AsciiDoc/ValidAdmonitionBlocks.yml b/.vale/styles/AsciiDoc/ValidAdmonitionBlocks.yml new file mode 100644 index 0000000..73d07a7 --- /dev/null +++ b/.vale/styles/AsciiDoc/ValidAdmonitionBlocks.yml @@ -0,0 +1,28 @@ +--- +extends: script +level: error +message: "Unterminated admonition block found in file." +link: https://docs.asciidoctor.org/asciidoc/latest/blocks/admonitions/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + admon_delim_regex := "^={4}$" + count := 0 + + for line in text.split(scope, "\n") { + if text.re_match(admon_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 // admonition block is closed, reset the count + matches = [] + } + } diff --git a/.vale/styles/AsciiDoc/ValidCodeBlocks.yml b/.vale/styles/AsciiDoc/ValidCodeBlocks.yml new file mode 100644 index 0000000..ffd4a52 --- /dev/null +++ b/.vale/styles/AsciiDoc/ValidCodeBlocks.yml @@ -0,0 +1,28 @@ +--- +extends: script +level: error +message: "Unterminated listing block found in file." +link: https://docs.asciidoctor.org/asciidoc/latest/verbatim/listing-blocks/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + listingblock_delim_regex := "^-{4}$" + count := 0 + + for line in text.split(scope, "\n") { + if text.re_match(listingblock_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 // listing block is closed, reset the count + matches = [] + } + } diff --git a/.vale/styles/AsciiDoc/ValidConditions.yml b/.vale/styles/AsciiDoc/ValidConditions.yml new file mode 100644 index 0000000..fdebe67 --- /dev/null +++ b/.vale/styles/AsciiDoc/ValidConditions.yml @@ -0,0 +1,33 @@ +--- +extends: script +level: error +message: "File contains unbalanced if statements." +link: https://docs.asciidoctor.org/asciidoc/latest/directives/ifdef-ifndef/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + if_regex := "^(ifdef::.+\\[\\]|ifndef::.+\\[\\]|ifeval::.*)" + endif_regex := "^endif::.*" + + for line in text.split(scope, "\n") { + if text.re_match(if_regex, line) { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if text.re_match(endif_regex, line) { + if len(matches) > 0 { + //remove the most recently added open ifdef match + matches = matches[:len(matches)-1] + } else if len(matches) == 0 { + //add orphan endif::[] statements + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + } + } diff --git a/.vale/styles/AsciiDoc/ValidTableBlocks.yml b/.vale/styles/AsciiDoc/ValidTableBlocks.yml new file mode 100644 index 0000000..063c901 --- /dev/null +++ b/.vale/styles/AsciiDoc/ValidTableBlocks.yml @@ -0,0 +1,28 @@ +--- +extends: script +level: error +message: "Unterminated table block found in file." +link: https://docs.asciidoctor.org/asciidoc/latest/tables/build-a-basic-table/ +scope: raw +script: | + text := import("text") + matches := [] + + //trim extra whitespace + scope = text.trim_space(scope) + //add a newline, it might be missing + scope += "\n" + + tbl_delim_regex := "^\\|={3,}$" + count := 0 + + for line in text.split(scope, "\n") { + if text.re_match(tbl_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 //code block is closed, reset the count + matches = [] + } + } diff --git a/.vale/styles/Localization.yml b/.vale/styles/Localization.yml new file mode 100644 index 0000000..d416db3 --- /dev/null +++ b/.vale/styles/Localization.yml @@ -0,0 +1,9 @@ +--- +extends: existence +ignorecase: true +level: warning +link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/TBD/ +message: "Avoid terms that are ambiguous and problematic in a localization context" +# source: https://github.com/redhat-documentation/vale-at-red-hat/issues/515 +tokens: + - should diff --git a/.vale/styles/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID.yml b/.vale/styles/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID.yml new file mode 100644 index 0000000..f9b0575 --- /dev/null +++ b/.vale/styles/OpenShiftAsciiDoc/AdditionalResourcesHeadingHasRoleID.yml @@ -0,0 +1,8 @@ +--- +extends: existence +scope: raw +level: suggestion +link: https://github.com/openshift/openshift-docs/blob/main/contributing_to_docs/doc_guidelines.adoc#additional-resources-sections +message: "Additional resources heading is missing the \"_additional-resources\" role attribute declaration" +raw: + - '(?|sh|.*\n\├|\[.*\]|\(.*\))' diff --git a/.vale/styles/OpenShiftAsciiDoc/IdHasContextVariable.yml b/.vale/styles/OpenShiftAsciiDoc/IdHasContextVariable.yml new file mode 100644 index 0000000..8178d3d --- /dev/null +++ b/.vale/styles/OpenShiftAsciiDoc/IdHasContextVariable.yml @@ -0,0 +1,8 @@ +--- +extends: existence +scope: raw +level: error +link: https://github.com/openshift/openshift-docs/blob/main/contributing_to_docs/doc_guidelines.adoc#anchoring-in-module-files +message: "ID is missing the \"_{context}\" variable at the end of the ID." +raw: + - '(?) are matching +$ tengo MatchingDotCallouts.tengo +*/ + +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" + +num_codeblock_callouts := 0 +num_callouts := 0 +codeblock_callout_regex := ".+<(\\.)>" +callout_regex := "^<(\\.)>" + +for line in text.split(scope, "\n") { + if text.re_match(codeblock_callout_regex, line) { + //restart for new listingblock + num_callouts = 0 + //account for lines with multiple callouts + num_callouts_in_line := text.count(line, "<.>") + if num_callouts_in_line > 1 { + num_codeblock_callouts = num_codeblock_callouts + num_callouts_in_line + } else { + num_codeblock_callouts++ + } + } + + if text.re_match(callout_regex, line) { + num_callouts++ + if num_callouts > num_codeblock_callouts { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + if num_callouts == num_codeblock_callouts { + num_callouts = 0 + num_codeblock_callouts = 0 + } + } +} + + +if len(matches) == 0 { + fmt.println("Dot callouts are balanced") +} else { + fmt.println(matches) +} diff --git a/scripts/MatchingNumberedCallouts.tengo b/scripts/MatchingNumberedCallouts.tengo new file mode 100644 index 0000000..cfaac7c --- /dev/null +++ b/scripts/MatchingNumberedCallouts.tengo @@ -0,0 +1,56 @@ +/* +Tengo Language +Checks that numbered callouts (<\d+>) are matching +$ tengo MatchingNumberedCallouts.tengo +*/ + +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" + +num_codeblock_callouts := 0 +num_callouts := 0 +codeblock_callout_regex := ".(<\\d+>)+" +callout_regex := "^<(\\d+)>" + +for line in text.split(scope, "\n") { + if text.re_match(codeblock_callout_regex, line) { + //restart for new listingblock + num_callouts = 0 + fmt.println(line) + //account for lines with multiple callouts + for i := 1; i < len(line); i++ { + //text.count must be str, not regex + str := "<" + i + ">" + num_callouts_in_line := text.count(line, str) + num_codeblock_callouts += num_callouts_in_line + } + } + + if text.re_match(callout_regex, line) { + num_callouts++ + if num_callouts > num_codeblock_callouts { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + if num_callouts == num_codeblock_callouts { + num_callouts = 0 + num_codeblock_callouts = 0 + } + } +} + +if len(matches) == 0 { + fmt.println("Numbered callouts are balanced") +} else { + fmt.println(matches) +} diff --git a/scripts/SequentialNumberedCallouts.tengo b/scripts/SequentialNumberedCallouts.tengo new file mode 100644 index 0000000..2eee497 --- /dev/null +++ b/scripts/SequentialNumberedCallouts.tengo @@ -0,0 +1,53 @@ +/* + Tengo Language + Checks that callouts outside the listing block are sequential + $ tengo SequentialNumberedCallouts.tengo +*/ + +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" + +prev_num := 0 +callout_regex := "^<(\\d+)>" +listingblock_delim_regex := "^-{4,}$" + +for line in text.split(scope, "\n") { + //reset count if we hit a listing block delimiter + if text.re_match(listingblock_delim_regex, line) { + prev_num = 0 + } + + if text.re_match(callout_regex, line) { + callout := text.re_find("<(\\d+)>", line) + for key, value in callout { + //trim angle brackets from string + trimmed := callout[key][0]["text"] + trimmed = text.trim_prefix(trimmed, "<") + trimmed = text.trim_suffix(trimmed, ">") + //cast string > int + num := text.atoi(trimmed) + //start counting + if num != prev_num+1 { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + prev_num = num + } + } +} + +if len(matches) == 0 { + fmt.println("Callouts are sequential") +} else { + fmt.println(matches) +} diff --git a/scripts/ValidAdmonitionBlocks.tengo b/scripts/ValidAdmonitionBlocks.tengo new file mode 100644 index 0000000..8e03703 --- /dev/null +++ b/scripts/ValidAdmonitionBlocks.tengo @@ -0,0 +1,37 @@ +/* + Tengo Language + $ tengo ValidAdmonitionBlocks.tengo +*/ + +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" + +admon_delim_regex := "^={4}$" +count := 0 + +for line in text.split(scope, "\n") { + if text.re_match(admon_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 // admonition block is closed, reset the count + matches = [] + } +} + +if len(matches) == 0 { + fmt.println("Valid admonitions") +} else { + fmt.println(matches) +} \ No newline at end of file diff --git a/scripts/ValidCodeBlocks.tengo b/scripts/ValidCodeBlocks.tengo new file mode 100644 index 0000000..16e8433 --- /dev/null +++ b/scripts/ValidCodeBlocks.tengo @@ -0,0 +1,37 @@ +/* + Tengo Language + $ tengo ValidCodeBlocks.tengo +*/ + +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" + +listingblock_delim_regex := "^-{4}$" +count := 0 + +for line in text.split(scope, "\n") { + if text.re_match(listingblock_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 // listing block is closed, reset the count + matches = [] + } +} + +if len(matches) == 0 { + fmt.println("Valid codeblocks") +} else { + fmt.println(matches) +} \ No newline at end of file diff --git a/scripts/ValidConditions.tengo b/scripts/ValidConditions.tengo new file mode 100644 index 0000000..2a4a73d --- /dev/null +++ b/scripts/ValidConditions.tengo @@ -0,0 +1,42 @@ +/* + Tengo Language + $ tengo ValidConditions.tengo +*/ + +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" + +if_regex := "^(ifdef::.+\\[\\]|ifndef::.+\\[\\]|ifeval::.*)" +endif_regex := "^endif::.*" + +for line in text.split(scope, "\n") { + if text.re_match(if_regex, line) { + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if text.re_match(endif_regex, line) { + if len(matches) > 0 { + //remove the most recently added open ifdef match + matches = matches[:len(matches)-1] + } else if len(matches) == 0 { + //add orphan endif::[] statements + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } + } +} + +if len(matches) == 0 { + fmt.println("Valid conditions") +} else { + fmt.println(matches) +} diff --git a/scripts/ValidTableBlocks.tengo b/scripts/ValidTableBlocks.tengo new file mode 100644 index 0000000..15f10db --- /dev/null +++ b/scripts/ValidTableBlocks.tengo @@ -0,0 +1,33 @@ +/* + Tengo Language + $ tengo ValidTableBlocks.tengo +*/ + +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" + +tbl_delim_regex := "^\\|={3,}$" +count := 0 + +for line in text.split(scope, "\n") { + if text.re_match(tbl_delim_regex, line) { + count += 1 + start := text.index(scope, line) + matches = append(matches, {begin: start, end: start + len(line)}) + } else if count > 1 { + count = 0 //code block is closed, reset the count + matches = [] + } +} + +fmt.println(matches) \ No newline at end of file diff --git a/scripts/validate-vale-rules.sh b/scripts/validate-vale-rules.sh new file mode 100755 index 0000000..d12ca14 --- /dev/null +++ b/scripts/validate-vale-rules.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Copyright (c) 2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Fail on errors + +set -e + +Rule() { + DIR=".vale/fixtures/$RULE" + echo "$DIR" + VALIDALERTSCOUNT="$(vale --config="$DIR/.vale.ini" --no-exit --output=line "$DIR/testvalid.adoc" | wc -l)" + INVALIDALERTSCOUNT="$(vale --config="$DIR/.vale.ini" --no-exit --output=line "$DIR/testinvalid.adoc" | wc -l)" + INVALIDLINES="$(grep -c "//vale-fixture" "$DIR/testinvalid.adoc" || true)" + INVALIDGAP=$((INVALIDLINES - INVALIDALERTSCOUNT)) + if [ "$VALIDALERTSCOUNT" -gt 0 ] + then + echo "$VALIDALERTSCOUNT ERROR(s) in $DIR/testvalid.adoc for .vale/styles/$RULE.yml" + TOTAL=$(( TOTAL + VALIDALERTSCOUNT )) + fi + if [ $INVALIDGAP -eq 0 ] + then + true //no errors + else + #handle error count or "//vale-fixture" string count mismatches + TOTAL=$(( TOTAL + INVALIDGAP )) + if [ $TOTAL -lt 0 ] + then + TOTAL=$((TOTAL * -1)) + fi + echo "$TOTAL ERROR(s) in $DIR/testinvalid.adoc / .vale/styles/$DIR.yml" + fi +} + +# This scripts runs the suite for each rule in the `AsciiDoc` style. +TOTAL=0 +for RULE in $(find .vale/styles/ -name '*.yml' | cut -d/ -f 3,4 | cut -d. -f1 | sort) +do + Rule +done + +echo "$TOTAL tests to fix" +exit $TOTAL \ No newline at end of file