Skip to content

Commit 47d6ca0

Browse files
Add information about configuration (#39)
* Add [Configuration](https://github.com/Azure/bicep-refdocs-generator/blob/main/docs/configuration.md) for information on how to customize the generation process. * Reorganize some code and fix tests.
1 parent 016143a commit 47d6ca0

File tree

36 files changed

+479
-121
lines changed

36 files changed

+479
-121
lines changed

README.md

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,14 @@
11
# Template reference
22

3-
This repo contains the code for generating template reference documentation. It uses files from the **generated** folder in [bicep-types-az](https://github.com/Azure/bicep-types-az) as the source files.
3+
This repo contains the code for generating [Azure template reference documentation](https://learn.microsoft.com/azure/templates/).
44

5-
## Accessing Generated Files
5+
## Configuring
66

7-
Every push to the `main` branch on this repo will trigger the [Generate GitHub Action](https://github.com/Azure/bicep-refdocs-generator/actions/workflows/generate.yml) which will run generation and upload results as an artifact named "generated".
8-
9-
Download this artifact (see [here](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/downloading-workflow-artifacts) for info), and unzip it. This will give you the full generated docs folder structure.
10-
11-
You can also trigger the Generate action to run on demand (see [here](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow) for info) to force generation with the most up-to-date copy of [bicep-types-az](https://github.com/Azure/bicep-types-az).
7+
See [Configuration](./docs/configuration.md) for information on how you can customize the generation process with remarks, code samples, and descriptions.
128

139
## Development
1410

15-
### Debugging
16-
17-
In VSCode, use the "Launch CLI" debug target to start the application in debug mode.
18-
19-
### Running tests
20-
21-
Run `dotnet test` to run the test suite.
22-
23-
### Updating baselines
24-
25-
If a test failure requires updating the baselines, follow the instructions and run the commands supplied in the error message.
26-
27-
If you want to update all of the baselines in one go, run:
28-
```sh
29-
./scripts/update_baselines.sh
30-
```
31-
32-
### Building
33-
34-
Run `dotnet build` to build this project.
35-
36-
## Using the CLI
37-
38-
After building the .NET solution, you can use the CLI by running:
39-
40-
```sh
41-
./src/TemplateRefGenerator/bin/Debug/net8.0/TemplateRefGenerator
42-
```
43-
44-
If you run this command without supplying any arguments, you will see a help message giving information on the supported arguments.
45-
46-
Here's an example of how you can run the CLI tool:
47-
```sh
48-
src/TemplateRefGenerator/bin/Debug/net8.0/TemplateRefGenerator --source-folder ../bicep-types-az/generated --output-folder ./generated
49-
```
50-
51-
To get detailed logging, use the `--verbose` flag.
11+
See [Developer Guide](./docs/dev_guide.md) for a developer guide on how to use this repo.
5212

5313
## Contributing
5414

docs/configuration.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Configuration
2+
3+
There are various configuration files that can be used to customize the behavior for the generator. This page explains where to find them and how to use them.
4+
5+
The configuration files all have JSON schemas associated with them. Open them with an IDE like VSCode to get real-time validation.
6+
7+
## Samples
8+
9+
This file can be found under [settings/samples/samples.json](../settings/samples/samples.json). It is used to configure the generation process to include links to external code samples for different resource types. The schema is available [here](../settings/samples.schema.json).
10+
11+
`samples.json` is not manually maintained. It can be updated by running [scripts/UpdateSamples.ps1](../scripts/UpdateSamples.ps1).
12+
13+
## Config
14+
15+
This file can be found under [settings/config/config.json](../settings/config/config.json), and can be used to configure the generation process. The schema is available [here](../settings/config.schema.json).
16+
17+
`config.json` contains central config for:
18+
* `TocTitleMapping`: used to generate custom page titles for different resource provider namespaces.
19+
* `ExcludedProviders`: a list of provider namespaces that should be excluded from docs generation.
20+
21+
## Remarks
22+
23+
These set of files can be found under [settings/remarks/<provider_namespace>/remarks.json](../settings/remarks/<provider_namespace>/remarks.json), and can be used to add customizations to different doc pages. The schema is available [here](../settings/remarks.schema.json).
24+
25+
For example, [remarks/microsoft.resources/remarks.json](../settings/remarks/microsoft.resources/remarks.json) can be used to customize documents for the Microsoft.Resources provider namespace.
26+
27+
`remarks.json` contains the following configuration options:
28+
* `DeploymentRemarks`: Can be used to add custom markdown with information on deploying a particular resource type. For example, explaining some of the quirks.
29+
* `ResourceRemarks`: Can be used to add custom remarks in markdown format about a particular resource type. See [here](https://github.com/Azure/bicep-refdocs-generator/blob/016143aa9375ba0ce62255fed1fad8905cfe75bf/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.keyvault/2023-07-01/vaults.md?plain=1#L29-L35) for an example of what the customized output looks like.
30+
* `PropertyRemarks`: Can be used to replace the description markdown for a particular resource type property.
31+
* `BicepSamples`: A list of `.bicep` files that will be added as samples to documentation. See [here](https://github.com/Azure/bicep-refdocs-generator/blob/016143aa9375ba0ce62255fed1fad8905cfe75bf/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md?plain=1#L61-L75) for an example of what the customized looks like.

docs/dev_guide.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Developer Guide
2+
3+
## Accessing Generated Files
4+
5+
Every push to the `main` branch on this repo will trigger the [Generate GitHub Action](https://github.com/Azure/bicep-refdocs-generator/actions/workflows/generate.yml) which will run generation and upload results as an artifact named "generated".
6+
7+
Download this artifact (see [here](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/downloading-workflow-artifacts) for info), and unzip it. This will give you the full generated docs folder structure.
8+
9+
You can also trigger the Generate action to run on demand (see [here](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow) for info) to force generation with the most up-to-date copy of [bicep-types-az](https://github.com/Azure/bicep-types-az).
10+
11+
## Development
12+
13+
### Debugging
14+
15+
In VSCode, use the "Launch CLI" debug target to start the application in debug mode.
16+
17+
### Running tests
18+
19+
Run `dotnet test` to run the test suite.
20+
21+
### Updating baselines
22+
23+
If a test failure requires updating the baselines, follow the instructions and run the commands supplied in the error message.
24+
25+
If you want to update all of the baselines in one go, run:
26+
```sh
27+
./scripts/update_baselines.sh
28+
```
29+
30+
### Building
31+
32+
Run `dotnet build` to build this project.
33+
34+
## Using the CLI
35+
36+
After building the .NET solution, you can use the CLI by running:
37+
38+
```sh
39+
./src/TemplateRefGenerator/bin/Debug/net8.0/TemplateRefGenerator
40+
```
41+
42+
If you run this command without supplying any arguments, you will see a help message giving information on the supported arguments.
43+
44+
Here's an example of how you can run the CLI tool:
45+
```sh
46+
src/TemplateRefGenerator/bin/Debug/net8.0/TemplateRefGenerator --source-folder ../bicep-types-az/generated --output-folder ./generated
47+
```
48+
49+
To get detailed logging, use the `--verbose` flag.

scripts/GetQuickstartLinks.ps1 renamed to scripts/UpdateSamples.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Param (
55
$ErrorActionPreference = "Stop"
66

77
$QuickStartsRepoPath = Resolve-Path $QuickStartsRepoPath
8-
$OutputPath = Join-Path $PSScriptRoot "../src/TemplateRefGenerator/Files/samples/samples.json"
8+
$OutputPath = Join-Path $PSScriptRoot "../settings/samples/samples.json"
99

1010
function GetResourceTypes {
1111
param([PSCustomObject] $template)
@@ -49,7 +49,7 @@ foreach ($metadataPath in $metadataPaths) {
4949
}
5050

5151
$samples = [ordered]@{
52-
"`$schema" = "../samples.schema.json";
52+
"`$schema" = "../schemas/samples.schema.json";
5353
QuickstartLinks = $quickstartLinks;
5454
}
5555

src/TemplateRefGenerator/Files/config/config.json renamed to settings/config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../config.schema.json",
2+
"$schema": "../schemas/config.schema.json",
33
"TocTitleMapping": {
44
"microsoft.aad": "AAD",
55
"microsoft.aadiam": "Aadiam",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../remarks.schema.json",
2+
"$schema": "../../schemas/remarks.schema.json",
33
"ResourceRemarks": [
44
{
55
"ResourceTypes": [

src/TemplateRefGenerator/Files/remarks/microsoft.authorization/remarks.json renamed to settings/remarks/microsoft.authorization/remarks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../remarks.schema.json",
2+
"$schema": "../../schemas/remarks.schema.json",
33
"ResourceRemarks": [
44
{
55
"ResourceTypes": [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../remarks.schema.json",
2+
"$schema": "../../schemas/remarks.schema.json",
33
"ResourceRemarks": [
44
{
55
"ResourceTypes": [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../remarks.schema.json",
2+
"$schema": "../../schemas/remarks.schema.json",
33
"ResourceRemarks": [
44
{
55
"ResourceTypes": [

src/TemplateRefGenerator/Files/remarks/microsoft.dbformysql/remarks.json renamed to settings/remarks/microsoft.dbformysql/remarks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../remarks.schema.json",
2+
"$schema": "../../schemas/remarks.schema.json",
33
"ResourceRemarks": [
44
{
55
"ResourceTypes": [

0 commit comments

Comments
 (0)