Skip to content

Commit 74cc195

Browse files
Add docs to built-in policies
Document the builtin policy statics using the original policy name and a short description copied from the policy file as summary, and the raw content of the policy as detailed documentation. (Because of the macro indirection, the 'source' link generated by rustdoc is kinda useless, so this provides a replacement.)
1 parent 44be032 commit 74cc195

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

src/policy/builtin.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,23 @@ impl Deref for BuiltInPolicy {
4141

4242
macro_rules! define_builtin_policies {
4343
($(
44-
$const_name:ident = $policy_name:literal
44+
$const_name:ident = $policy_name:literal -- $description:literal
4545
),* $(,)?) => {
4646
// Define the static constants
4747
$(
48+
#[doc = concat!("`", $policy_name, "`: ", $description)]
49+
#[doc = ""]
50+
51+
// We include the policy source in the documentation: it's an easy way to provide the
52+
// user with full information about the policy and it's hard to document a policy
53+
// without just paraphrasing its content anyway.
54+
#[doc = "```text"]
55+
#[doc = include_str!(concat!(
56+
"../../builtin-policies/",
57+
$policy_name,
58+
".builtin-policy"
59+
))]
60+
#[doc = "```"]
4861
pub static $const_name: BuiltInPolicy = BuiltInPolicy {
4962
name: $policy_name,
5063
policy: LazyLock::new(|| {
@@ -86,9 +99,16 @@ macro_rules! define_builtin_policies {
8699

87100
// All built-in policies defined here in one single place.
88101
// Multiple invocations not possible since this invocation emits the `builtin` lookup function.
102+
//
103+
// The syntax is
104+
// <static name> = "<policy name>" -- "<one-line description>"
105+
// Where
106+
// <policy name> is the policy name defined by the Sigsum project
107+
// <static name> is <policy name> converted to uppercase and with '-' replaced by '_'
108+
// <one-line description> is the comment line at the top of the policy file
89109
define_builtin_policies! {
90-
SIGSUM_TEST1_2025 = "sigsum-test1-2025",
91-
SIGSUM_TEST2_2025 = "sigsum-test2-2025",
92-
SIGSUM_TEST_2025_3 = "sigsum-test-2025-3",
93-
SIGSUM_GENERIC_2025_1 = "sigsum-generic-2025-1",
110+
SIGSUM_TEST1_2025 = "sigsum-test1-2025" -- "Policy using the sigsum test log at test.sigsum.org/barreleye",
111+
SIGSUM_TEST2_2025 = "sigsum-test2-2025" -- "Policy using the sigsum test log at test.sigsum.org/barreleye",
112+
SIGSUM_TEST_2025_3 = "sigsum-test-2025-3" -- "Policy using two sigsum test logs at test.sigsum.org/barreleye and serviceberry.tlog.stagemole.eu",
113+
SIGSUM_GENERIC_2025_1 = "sigsum-generic-2025-1" -- "This is a Sigsum trust policy that has been vetted by the Sigsum project",
94114
}

0 commit comments

Comments
 (0)