Skip to content

Commit f9f8c8f

Browse files
committed
Generate config documentation from application.properties
Leverages the `GenerateConfigDocs` JBang script (https://github.com/DependencyTrack/jbang-catalog/blob/main/GenerateConfigDocs.java) to generate reference documentation from the `application.properties` file. This makes `application.properties` the single source of truth for configuration options. We no longer need to copy-paste its contents to multiple places for documentation purposes. The documentation is re-generated automatically whenever `application.properties` changes. This is already done for the Hyades project (https://github.com/DependencyTrack/hyades/blob/2f95363fbf51423876a8eb2c7f0bc55a53ba85f9/DEVELOPING.md?plain=1#L11-L61) and turned out to be useful, so backporting it here. Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent 1f2cc28 commit f9f8c8f

6 files changed

Lines changed: 3039 additions & 628 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This file is part of Dependency-Track.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
name: Update Config Documentation
18+
19+
on:
20+
push:
21+
branches:
22+
- master
23+
paths:
24+
- ".github/workflows/update-config-docs.yml"
25+
- "dev/scripts/config-docs.md.peb"
26+
- "src/main/resources/application.properties"
27+
workflow_dispatch: { }
28+
29+
permissions: { }
30+
31+
jobs:
32+
generate-docs:
33+
name: Generate Documentation
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 5
36+
permissions:
37+
contents: write
38+
pull-requests: write
39+
if: "${{ github.repository_owner == 'DependencyTrack' }}"
40+
steps:
41+
- name: Checkout Repository
42+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # tag=v4.1.6
43+
- name: Generate Documentation
44+
uses: jbangdev/jbang-action@74844c9631cf1f35650427323e9bb3ffa41dfbd9 # tag=v0.115.0
45+
with:
46+
trust: https://github.com/DependencyTrack/jbang-catalog
47+
script: gen-config-docs@DependencyTrack
48+
scriptargs: >-
49+
--template ./dev/scripts/config-docs.md.peb
50+
--output docs/_docs/getting-started/configuration-apiserver.md
51+
./src/main/resources/application.properties
52+
- name: Create Pull Request
53+
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # tag=v6.0.5
54+
with:
55+
add-paths: "docs/_docs/getting-started/configuration-apiserver.md"
56+
branch: update-config-docs
57+
body: "Updates configuration documentation."
58+
commit-message: Update config docs
59+
delete-branch: true
60+
labels: documentation
61+
signoff: true
62+
title: Update config docs

dev/scripts/config-docs.md.peb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Configuration - API Server
3+
category: Getting Started
4+
chapter: 1
5+
order: 6
6+
---
7+
<!--
8+
GENERATED. DO NOT EDIT.
9+
10+
Generated with: {{ generateCommand }}
11+
-->
12+
{% for entry in propertiesByCategory %}
13+
### {{ entry.key }}
14+
15+
{% for property in entry.value -%}
16+
#### {{ property.name }}
17+
18+
{{ property.description }}
19+
20+
<table>
21+
<tbody style="border: 0">
22+
<tr>
23+
<th style="text-align: right">Required</th>
24+
<td style="border-width: 0">{{ property.required ? "Yes" : "No" }}</td>
25+
</tr>
26+
<tr>
27+
<th style="text-align: right">Type</th>
28+
<td style="border-width: 0">{{ property.type }}</td>
29+
</tr>
30+
{% if property.validValues -%}
31+
<tr>
32+
<th style="text-align: right">Valid Values</th>
33+
<td style="border-width: 0">{{ property.validValues }}</td>
34+
</tr>
35+
{% endif -%}
36+
<tr>
37+
<th style="text-align: right">Default</th>
38+
<td style="border-width: 0">{{ property.defaultValue }}</td>
39+
</tr>
40+
{% if property.example -%}
41+
<tr>
42+
<th style="text-align: right">Example</th>
43+
<td style="border-width: 0">{{ property.example }}</td>
44+
</tr>
45+
{% endif -%}
46+
<tr>
47+
<th style="text-align: right">ENV</th>
48+
<td style="border-width: 0">{{ property.env }}</td>
49+
</tr>
50+
</tbody>
51+
</table>
52+
53+
{% if not loop.last %}
54+
---
55+
{% endif %}
56+
{% endfor %}
57+
{% endfor %}

0 commit comments

Comments
 (0)