Skip to content

Commit

Permalink
Add source link for rule in docs #2115
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite committed Sep 30, 2023
1 parent 66abf29 commit 8070f1a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@
"VARIANT": "6.0-bullseye-slim"
}
},
"remoteUser": "vscode"
"remoteUser": "vscode",
"forwardPorts": [
8000
]
}
3 changes: 3 additions & 0 deletions docs/CHANGELOG-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ What's changed since pre-release v1.30.0-B0080:
- Updated `Azure.AKS.Version` to use latest stable version `1.26.6` by @BernieWhite.
[#2404](https://github.com/Azure/PSRule.Rules.Azure/issues/2404)
- Use `AZURE_AKS_CLUSTER_MINIMUM_VERSION` to configure the minimum version of the cluster.
- General improvements:
- Add source link for rule in docs by @BernieWhite.
[#2115](https://github.com/Azure/PSRule.Rules.Azure/issues/2115)
- Engineering:
- Updated resource providers and policy aliases.
[#2442](https://github.com/Azure/PSRule.Rules.Azure/pull/2442)
Expand Down
7 changes: 7 additions & 0 deletions docs/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def replace_maml(markdown: str, page: mkdocs.structure.nav.Page, config: mkdocs.
if page.meta.get("resource", "None") != "None":
markdown = markdown.replace("<!-- TAGS -->", " · [:octicons-container-24: " + page.meta['resource'] + "](resource.md#" + page.meta['resource'].lower().replace(" ", "-") + ")\r<!-- TAGS -->")

if page.meta.get('source', 'None') != 'None':
markdown = markdown.replace("<!-- TAGS -->", " · [:octicons-file-code-24: Rule](" + page.meta['source'] + ")\r<!-- TAGS -->")

if page.meta.get('release', 'None') == 'preview':
markdown = markdown.replace("<!-- TAGS -->", " · :octicons-beaker-24: Preview\r<!-- TAGS -->")

Expand Down Expand Up @@ -128,6 +131,10 @@ def read_metadata(page: mkdocs.structure.nav.Page):
description = data[name]['Synopsis']
page.meta['description'] = description

if page.meta.get('rule', '') != '' and data.get(name, None) != None and data[name].get('Source', None) != None:
page.meta['source'] = data[name]['Source']


page.meta['tags'] = tags


Expand Down
2 changes: 2 additions & 0 deletions pipeline.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ task BuildRuleDocs Build, Dependencies, {
Recommendation = $_.Info.Recommendation
Pillar = $_.Tag.'Azure.WAF/pillar'
Control = $_.Tag.'Azure.MCSB.v1/control'
Source = "https://github.com/Azure/PSRule.Rules.Azure/blob/main/src/PSRule.Rules.Azure/rules/$(($_.Source.Path -split '/')[-1])"
}
}
$metadata | ConvertTo-Json -Depth 5 | Set-Content -Path ./docs/en/rules/metadata.json -Force;
Expand All @@ -407,6 +408,7 @@ task BuildRuleDocs Build, Dependencies, {
Recommendation = $_.Info.Recommendation
Pillar = $_.Tag.'Azure.WAF/pillar'
Control = $_.Tag.'Azure.MCSB.v1/control'
Source = "https://github.com/Azure/PSRule.Rules.Azure/blob/main/src/PSRule.Rules.Azure/rules/$(($_.Source.Path -split '/')[-1])"
}
}
$metadata | ConvertTo-Json -Depth 5 | Set-Content -Path ./docs/es/rules/metadata.json -Force;
Expand Down

0 comments on commit 8070f1a

Please sign in to comment.