INNER CODE UNIT · Go
func
open-policy-agent/conftest · document/metadata.go:70
func (s Section) Equal(s2 Section) bool {
if s.MarkdownHeading == s2.MarkdownHeading &&
s.RegoPackageName == s2.RegoPackageName &&
s.Annotations.Title == s2.Annotations.Title {
return true
}
return false
}
// ConvertAnnotationsToSections generates a more convenient struct that can be used to generate the doc
// First concern is to build a coherent title structure; the ideal case is that each package and each rule has a doc,
// but this is not guaranteed. I couldn't find a way to call `strings.Repeat` inside go-template; thus, the title symbol is
// directly provided as markdown (#, ##, ###, etc.)
// Second, the attribute RegoPackageName of ast.Annotations are not easy to use on go-template; thus, we extract it as a string
func ConvertAnnotationsToSections(as ast.FlatAnnotationsRefSet) (Document, error) {
var d Document