Skip to content

Commit

Permalink
Add tools/ dir and some handy utilities (#702)
Browse files Browse the repository at this point in the history
* Add tools/ dir and some handy utilities

The tools are intended for spec editors to use when authoring and/or
reviewing changes. They aren't incorporated into the spec publishing
process, but that could be considered in the future.

- tools/reformat_js - reformats JS blocks in the spec
- tools/lint.mjs - looks for convention violations and other glitches

The reformat_js tools has been applied to index.bs

* Update tools/reformat_js

Co-authored-by: Ningxin Hu <[email protected]>

* Rename exit_code to exitCode - camelCase FTW

* rename with extension for more clarity

* Include interpreter in instructions

* Add .clang-format and options

* add package.json for node dependencies

* Lint: add --verbose option

* Add tools to Makefile

* Improve documentation around normative references test

* Ignore local node files, mention install steps

* Article agreement in tools/lint.mjs comment

---------

Co-authored-by: Ningxin Hu <[email protected]>
Co-authored-by: Dwayne Robinson <[email protected]>
  • Loading branch information
3 people authored Jun 8, 2024
1 parent f6a9af1 commit 74b9831
Show file tree
Hide file tree
Showing 9 changed files with 760 additions and 332 deletions.
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium

# Stick with 2 spaces for both blocks and continuations.
ContinuationIndentWidth: 2

# Arguments either on one line or each on their own line.
BinPackArguments: false
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/index.html
/index.html
/tools/node_modules
/tools/package-lock.json
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.PHONY: clean

all: index.html

index.html: index.bs
python3 tools/reformat-js.py
ifdef online
curl https://api.csswg.org/bikeshed/ -F [email protected] -F output=err | tee /dev/stderr | grep -e "ERROR" > /dev/null; \
if [ $$? -eq 0 ]; \
Expand All @@ -11,3 +14,7 @@ else
# bikeshed -f spec index.bs
bikeshed --die-on=fatal spec index.bs
endif
node tools/lint.mjs --verbose

clean:
rm -f index.html
2 changes: 2 additions & 0 deletions docs/SpecCodingConventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This document captures the WebNN spec repo conventions. The intended audience is editors and contributors to the specification.

When updating these conventions, consider whether an automated check can be added to the [lint tool](../tools/lint.mjs) to help catch issues.

## Resources

* [Writing Procedural Specs](https://garykac.github.io/procspec/)
Expand Down
Loading

0 comments on commit 74b9831

Please sign in to comment.