Skip to content

Commit b6fdbce

Browse files
feat:
1 parent 821375e commit b6fdbce

File tree

6 files changed

+107
-3
lines changed

6 files changed

+107
-3
lines changed

Bicep.Docs.Tests/BasicTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ public class BasicTests
55
[Test]
66
public void Basic_WhenBicepFileIsProvided_DocumentationShouldBeGenerated()
77
{
8-
Program.Main(["--template", "templates/basic.bicep"]);
8+
Program.Main(["--template", "templates/basic/basic.bicep"]);
9+
}
10+
11+
[Test]
12+
public void Basic_WhenJsonFileIsProvided_DocumentationShouldBeGenerated()
13+
{
14+
Program.Main(["--template", "templates/json/basic.json"]);
915
}
1016
}

Bicep.Docs.Tests/templates/basic.bicep renamed to Bicep.Docs.Tests/templates/basic/basic.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
metadata BicepDocs = {
2-
examplesDirectory: 'templates/examples'
2+
examplesDirectory: 'templates/basic/examples'
33
}
44

55
@description('Name of the Azure Container Registry')
File renamed without changes.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_generator": {
6+
"name": "bicep",
7+
"version": "0.26.54.24096",
8+
"templateHash": "11197120595624797346"
9+
},
10+
"BicepDocs": {
11+
"examplesDirectory": "templates/json/examples"
12+
}
13+
},
14+
"parameters": {
15+
"parAcrName": {
16+
"type": "string",
17+
"metadata": {
18+
"description": "Name of the Azure Container Registry"
19+
}
20+
},
21+
"parLocation": {
22+
"type": "string",
23+
"defaultValue": "[resourceGroup().location]",
24+
"metadata": {
25+
"description": "Location of the Azure Container Registry"
26+
}
27+
},
28+
"parSku": {
29+
"type": "string",
30+
"defaultValue": "Basic",
31+
"allowedValues": [
32+
"Basic",
33+
"Standard",
34+
"Premium"
35+
],
36+
"metadata": {
37+
"description": "The SKU of the Azure Container Registry"
38+
}
39+
},
40+
"parSqlName": {
41+
"type": "string",
42+
"metadata": {
43+
"description": "Name of the Azure SQL Server"
44+
}
45+
},
46+
"parSqlAdminLogin": {
47+
"type": "securestring",
48+
"metadata": {
49+
"description": "Password for the Azure SQL Server admin user"
50+
}
51+
}
52+
},
53+
"resources": [
54+
{
55+
"type": "Microsoft.ContainerRegistry/registries",
56+
"apiVersion": "2023-07-01",
57+
"name": "[parameters('parAcrName')]",
58+
"location": "[parameters('parLocation')]",
59+
"sku": {
60+
"name": "[parameters('parSku')]"
61+
},
62+
"properties": {
63+
"adminUserEnabled": false
64+
}
65+
},
66+
{
67+
"type": "Microsoft.Sql/servers",
68+
"apiVersion": "2021-11-01",
69+
"name": "[parameters('parSqlName')]",
70+
"location": "[parameters('parLocation')]",
71+
"properties": {
72+
"administratorLogin": "admin",
73+
"administratorLoginPassword": "[parameters('parSqlAdminLogin')]"
74+
}
75+
}
76+
],
77+
"outputs": {
78+
"acrId": {
79+
"type": "string",
80+
"value": "[resourceId('Microsoft.ContainerRegistry/registries', parameters('parAcrName'))]"
81+
},
82+
"sqlId": {
83+
"type": "string",
84+
"value": "[resourceId('Microsoft.Sql/servers', parameters('parSqlName'))]"
85+
}
86+
}
87+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
param parLocation string = 'polandcentral'
2+
3+
module basic '../basic.bicep' = {
4+
name: 'basic'
5+
params: {
6+
parAcrName: 'bicepdocsacr'
7+
parSqlAdminLogin: 'bicepdocsadmin'
8+
parSqlName: 'bicepdocssql'
9+
parLocation: parLocation
10+
}
11+
}

Bicep.Docs/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void Main(string[] args)
1515
if (File.Exists(o.TemplatePath))
1616
{
1717
var file = new FileInfo(o.TemplatePath);
18-
var rawTemplate = BicepCompiler.Compile(file, CancellationToken.None);
18+
var rawTemplate = file.Extension == ".json" ? File.ReadAllText(o.TemplatePath) : BicepCompiler.Compile(file, CancellationToken.None);
1919

2020
#if DEBUG
2121
Console.WriteLine(rawTemplate);

0 commit comments

Comments
 (0)