Documentation
¶
Overview ¶
Package smarttags parses PostGraphile-style "smart comments": lines at the start of a database COMMENT beginning with '@' are machine-readable tags, everything after the first non-tag line is the human description.
COMMENT ON TABLE users IS E'@name people\n@omit delete\nA user of the app.';
parses to {name: ["people"], omit: ["delete"]} plus "A user of the app.". The parser is shared by the smart-comments and advanced-filters plugins so both read the same syntax from the same catalog comments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tags ¶
Tags maps a tag name to its values, one entry per occurrence in the comment; a bare tag (no value) contributes an empty string. A nil Tags is valid and empty.
func Parse ¶
Parse splits a comment into its smart tags and the remaining description. Comments with no leading '@' line are returned unchanged with nil tags.
func (Tags) Omits ¶
Omits collects the actions named across all @omit occurrences (lowercased, split on commas and whitespace: "@omit create, update"). A bare @omit sets everything instead: the object is omitted entirely.
PostGraphile-V5-style @behavior tags contribute too: their negative tokens map onto omit actions (-insert -> create, -update -> update, -delete -> delete, -select -> read, -filter -> filter, -order -> order); other tokens are ignored.