-
Notifications
You must be signed in to change notification settings - Fork 477
Linter: Automate the generation of documentation for ink-docs
#1972
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a6fb3d0
feat(linter): Automate the generation of documentation for ink-docs
jubnzv 466f70d
Merge remote-tracking branch 'origin/master' into linter-docs
jubnzv 5dcc0b2
chore(script): Update after #2032 is merged
jubnzv a196595
chore(linter): Wrap in docstring to improve appearance
jubnzv 98bf33a
Update scripts/generate_linter_docs.sh
cmichi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,55 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 PATH" | ||
| echo "Creates or updates the documentation for ink_linting hosted at use.ink." | ||
| echo | ||
| echo "Arguments:" | ||
| echo " PATH Path to the local clone of https://github.com/paritytech/ink-docs" | ||
| echo | ||
| echo "Examples:" | ||
| echo " $0 ~/ink-docs" | ||
| } | ||
|
|
||
| if [ ! $# -eq 1 ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| ink_docs_dir="$1" | ||
| tmp_file=$(mktemp /tmp/linting_docs.XXXXXX.md) | ||
| had_update=0 | ||
| for lint_src in linting/{mandatory,extra}/src/*.rs; do | ||
| lint_name="$(basename "${lint_src%.*}")" | ||
| lint_doc_file="$ink_docs_dir/docs/linter/rules/$lint_name.md" | ||
| lint_doc_filestring="$(sed -n '/^declare_lint! {$/,/^}$/p' "$lint_src")" | ||
| [[ -z "$lint_doc_filestring" ]] && continue | ||
|
|
||
| # Save the extracted documentation to the temporary file | ||
| truncate -s 0 "$tmp_file" | ||
| { | ||
| echo "---" | ||
| echo "title: $lint_name" | ||
| echo "hide_title: true" | ||
| echo "description: $lint_name lint documentation" | ||
| echo "---" | ||
| echo "# $lint_name" | ||
| printf "%s" "$lint_doc_filestring" | sed -n 's/^\s*\/\/\/\s\?\(.*\)$/\1/;T;p' | ||
| } >> "$tmp_file" | ||
|
|
||
| if [[ ! -f "$lint_doc_file" ]]; then | ||
| echo "$lint_name: created documentation" | ||
| had_update=1 | ||
| mv "$tmp_file" "$lint_doc_file" | ||
| continue | ||
| fi | ||
|
|
||
| if cmp -s "$tmp_file" "$lint_doc_file"; then | ||
| echo "$lint_name: no changes" | ||
| else | ||
| echo "$lint_name: updated" | ||
| mv "$tmp_file" "$lint_doc_file" | ||
| fi | ||
| done | ||
|
|
||
| [[ $had_update -eq 1 ]] && echo -e "\nPlease add created documentation sections to $ink_docs_dir/sidebars.js" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.