Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[editorial] markdownlint in less then 1.5 sec #193

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: make check-file-and-folder-names-in-docs

- name: run markdownlint
run: make markdownlint
run: npx gulp lint-md

yamllint:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ make misspell-correction
- Add `## v{version} ({date})` under `## Unreleased`
- Send staging tag as PR for review.
- Create a tag `v{version}` on the merged PR and push remote.

[nvm]: https://github.com/nvm-sh/nvm/blob/master/README.md#installing-and-updating
2 changes: 0 additions & 2 deletions docs/general/general-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ Examples of where the `enduser.id` value is extracted from:
| [JavaEE/JakartaEE Servlet] | `javax.servlet.http.HttpServletRequest.getUserPrincipal()` |
| [Windows Communication Foundation] | `ServiceSecurityContext.Current.PrimaryIdentity` |

[Authorization]: https://tools.ietf.org/html/rfc7235#section-4.2
[OAuth 2.0 Access Token]: https://tools.ietf.org/html/rfc6749#section-3.3
[SAML 2.0 Assertion]: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html
[HTTP Basic/Digest Authentication]: https://tools.ietf.org/html/rfc2617
[OAuth 2.0 Bearer Token]: https://tools.ietf.org/html/rfc6750
Expand Down
2 changes: 2 additions & 0 deletions docs/general/trace-general.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ The following semantic conventions for spans are defined:
Apart from semantic conventions for traces, [metrics](metrics-general.md), [logs](logs-general.md), and [events](events-general.md),
OpenTelemetry also defines the concept of overarching [Resources](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.22.0/specification/resource/sdk.md) with their own
[Resource Semantic Conventions](/docs/resource/README.md).

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.22.0/specification/document-status.md
2 changes: 0 additions & 2 deletions docs/rpc/rpc-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ To avoid high cardinality, implementations should prefer the most stable of `ser
For client-side metrics `server.port` is required if the connection is IP-based and the port is available (it describes the server port they are connecting to).
For server-side spans `server.port` is optional (it describes the port the client is connecting from).

[network.transport]: /docs/general/general-attributes.md#network-attributes

### Service name

On the server process receiving and handling the remote procedure call, the service name provided in `rpc.service` does not necessarily have to match the [`service.name`][] resource attribute.
Expand Down
1 change: 0 additions & 1 deletion docs/rpc/rpc-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ This process could expose two RPC endpoints, one called `CurrencyQuotes` (= `rpc
In this example, spans representing client request should have their `peer.service` attribute set to `QuoteService` as well to match the server's `service.name` resource attribute.
Generally, a user SHOULD NOT set `peer.service` to a fully qualified RPC service name.

[network attributes]: /docs/general/general-attributes.md#server-and-client-attributes
[`service.name`]: /docs/resource/README.md#service
[`peer.service`]: /docs/general/general-attributes.md#general-remote-service-attributes

Expand Down
45 changes: 45 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const gulp = require("gulp");
const through2 = require("through2");
const markdownlint = require("markdownlint");
const yaml = require("js-yaml");
const fs = require("fs");

const markdownFiles = ["**/*.md", "!**/node_modules/**", "!**/.github/**"];
const config = yaml.load(fs.readFileSync("./.markdownlint.yaml", "utf8"));

let fileCounter = 0;

function markdownLintFile(file, encoding, callback) {
const options = {
files: [file.path],
config: config,
};

markdownlint(options, function (err, result) {
const _resultString = (result || "").toString();
// Result is of the form:
// "<file-path>:\s*<line-number>: <ID-and-message"
// Strip out the whitespace between the file-path and line number
// so that tools can jump directly to the line.
const resultString = _resultString.replace(
/([^:]+):\s*(\d+):(.*)/,
"$1:$2:$3",
);
if (resultString) console.log(resultString);
fileCounter++;
callback(null, file);
});
}

function lintMarkdown() {
return (
gulp
.src(markdownFiles)
.pipe(through2.obj(markdownLintFile))
.on("end", () => {
console.log(`Processed ${fileCounter} file${fileCounter == 1 ? '' : 's'}.`);
})
);
}

gulp.task("lint-md", lintMarkdown);
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"devDependencies": {
"gulp": "^4.0.2",
"js-yaml": "^4.1.0",
"markdown-link-check": "3.10.3",
"markdown-toc": "^1.2.0",
"markdownlint-cli": "0.31.0"
"markdownlint": "^0.29.0",
"markdownlint-cli": "0.31.0",
"prettier": "^3.0.0",
"through2": "^4.0.2"
},
"prettier": {
"proseWrap": "preserve"
}
}