Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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 avm/res/key-vault/vault/access-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module vault 'br/public:avm/res/key-vault/vault/access-policy:<version>' = {
params: { (...) }
}
```
For examples, please refer to the [Usage Examples](#usage-examples) section.
For examples, please refer to the main module's _Usage Examples_ section.

## Navigation

Expand Down
2 changes: 1 addition & 1 deletion avm/res/key-vault/vault/key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module vault 'br/public:avm/res/key-vault/vault/key:<version>' = {
params: { (...) }
}
```
For examples, please refer to the [Usage Examples](#usage-examples) section.
For examples, please refer to the main module's _Usage Examples_ section.

## Navigation

Expand Down
2 changes: 1 addition & 1 deletion avm/res/key-vault/vault/secret/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module vault 'br/public:avm/res/key-vault/vault/secret:<version>' = {
params: { (...) }
}
```
For examples, please refer to the [Usage Examples](#usage-examples) section.
For examples, please refer to the main module's _Usage Examples_ section.

## Navigation

Expand Down
20 changes: 14 additions & 6 deletions utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,9 @@ Mandatory. The template file content object to crawl data from
.PARAMETER ForceCacheRefresh
Optional. Define whether or not to force refresh cache data. Note, the cache automatically expires after 1 day.

.PARAMETER IsParentModule
Optional. Configures whether the module has any usages examples in its readme worth referencing

.EXAMPLE
Initialize-ReadMe -ReadMeFilePath 'C:/ResourceModules/modules/sql/managed-instances/administrators/readme.md' -FullModuleIdentifier 'sql/managed-instance/administrator' -TemplateFileContent @{ resource = @{}; ... }

Expand All @@ -2004,6 +2007,9 @@ function Initialize-ReadMe {
[Parameter(Mandatory = $true)]
[hashtable] $TemplateFileContent,

[Parameter(Mandatory = $true)]
[bool] $HasUsageExamples,

[Parameter()]
[switch] $ForceCacheRefresh
)
Expand Down Expand Up @@ -2080,7 +2086,7 @@ function Initialize-ReadMe {
' params: { (...) }',
'}',
'```',
'For examples, please refer to the [Usage Examples](#usage-examples) section.'
($HasUsageExamples ? 'For examples, please refer to the [Usage Examples](#usage-examples) section.' : 'For examples, please refer to the main module''s _Usage Examples_ section.')
)
}

Expand Down Expand Up @@ -2280,13 +2286,20 @@ function Set-ModuleReadMe {
$notes = @()
}

$isMultiScopeChildModule = $moduleRoot -match '[\/|\\](rg|sub|mg)\-scope$'
$isMultiScopeParentModule = ((Get-ChildItem -Directory -Path $moduleRoot) | Where-Object { $_.FullName -match '[\/|\\](rg|sub|mg)\-scope$' }).Count -gt 0

# If it's multi-scope child module, we need to check if its parent has tests
$hasTests = (Get-ChildItem -Path ($isMultiScopeChildModule ? (Split-Path $moduleRoot) : $moduleRoot) -Recurse -Filter 'main.test.bicep' -File -Force).count -gt 0

# Initialize readme
$inputObject = @{
ReadMeFilePath = $ReadMeFilePath
FullModuleIdentifier = $FullModuleIdentifier
TemplateFileContent = $templateFileContent
TemplateFilePath = $TemplateFilePath
ForceCacheRefresh = $ForceCacheRefresh
HasUsageExamples = $hasTests
}
$readMeFileContent = Initialize-ReadMe @inputObject

Expand All @@ -2303,11 +2316,6 @@ function Set-ModuleReadMe {
$readMeFileContent = Set-ResourceTypesSection @inputObject
}

$isMultiScopeChildModule = $moduleRoot -match '[\/|\\](rg|sub|mg)\-scope$'
$isMultiScopeParentModule = ((Get-ChildItem -Directory -Path $moduleRoot) | Where-Object { $_.FullName -match '[\/|\\](rg|sub|mg)\-scope$' }).Count -gt 0

# If it's multi-scope child module, we need to check if its parent has tests
$hasTests = (Get-ChildItem -Path ($isMultiScopeChildModule ? (Split-Path $moduleRoot) : $moduleRoot) -Recurse -Filter 'main.test.bicep' -File -Force).count -gt 0

if ($SectionsToRefresh -contains 'Usage examples' -and $hasTests) {
# Handle [Usage examples] section
Expand Down