Skip to content

Commit bfd42f3

Browse files
WiP: 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 content of the policy as detailed documentation. (Because of the macro inderection, the 'source' link generated by rustdoc is kinda useless, so this provides a replacement.)
1 parent 44be032 commit bfd42f3

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

src/policy/builtin.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,22 @@ 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+
50+
// We include the policy source in the documentation: it's an easy way to provide the
51+
// user with full information about the policy and it's hard to document a policy
52+
// without just paraphrasing its content anyway.
53+
#[doc = "```text"]
54+
#[doc = include_str!(concat!(
55+
"../../builtin-policies/",
56+
$policy_name,
57+
".builtin-policy"
58+
))]
59+
#[doc = "```"]
4860
pub static $const_name: BuiltInPolicy = BuiltInPolicy {
4961
name: $policy_name,
5062
policy: LazyLock::new(|| {
@@ -86,9 +98,16 @@ macro_rules! define_builtin_policies {
8698

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

0 commit comments

Comments
 (0)