Documentation
¶
Index ¶
- Constants
- Variables
- func ExampleStoreUsage()
- func RenderToMarkdown(t *template.Template, data interface{}, output io.Writer) (string, error)
- type HelpError
- type HelpPage
- type HelpSystem
- func (hs *HelpSystem) AddSection(section *Section)
- func (hs *HelpSystem) ComputeRenderData(userQuery *SectionQuery) (map[string]interface{}, bool)
- func (hs *HelpSystem) GetSectionWithSlug(slug string) (*Section, error)
- func (hs *HelpSystem) GetTopLevelHelpPage() *HelpPage
- func (hs *HelpSystem) LoadSectionsFromFS(f fs.FS, dir string) error
- func (hs *HelpSystem) PrintQueryDebug(queryDSL string, printQuery, printSQL bool) error
- func (hs *HelpSystem) QuerySections(query string) ([]*Section, error)
- func (hs *HelpSystem) RenderTopicHelp(topicSection *Section, options *RenderOptions) (string, error)
- func (hs *HelpSystem) RenderTopicHelpWithWriter(topicSection *Section, options *RenderOptions, output io.Writer) (string, error)
- type RenderOptions
- type Section
- func (s *Section) DefaultApplications() []*Section
- func (s *Section) DefaultExamples() []*Section
- func (s *Section) DefaultGeneralTopic() []*Section
- func (s *Section) DefaultTutorials() []*Section
- func (s *Section) IsForCommand(command string) bool
- func (s *Section) IsForFlag(flag string) bool
- func (s *Section) IsForTopic(topic string) bool
- func (s *Section) OtherApplications() []*Section
- func (s *Section) OtherExamples() []*Section
- func (s *Section) OtherTutorials() []*Section
- type SectionQuery
- func (s *SectionQuery) Clone() *SectionQuery
- func (s *SectionQuery) DontReturnApplications() *SectionQuery
- func (s *SectionQuery) DontReturnExamples() *SectionQuery
- func (s *SectionQuery) DontReturnTopics() *SectionQuery
- func (s *SectionQuery) DontReturnTutorials() *SectionQuery
- func (s *SectionQuery) FilterSections(sections ...*Section) *SectionQuery
- func (s *SectionQuery) FindSections(ctx context.Context, st *store.Store) ([]*Section, error)
- func (s *SectionQuery) GetOnlyQueryAsString() string
- func (s *SectionQuery) GetRequestedTypesAsString() string
- func (s *SectionQuery) HasOnlyQueries() bool
- func (s *SectionQuery) HasRestrictedReturnTypes() bool
- func (s *SectionQuery) IsOnlyTopLevel() bool
- func (s *SectionQuery) ResetOnlyQueries() *SectionQuery
- func (s *SectionQuery) ReturnAllTypes() *SectionQuery
- func (s *SectionQuery) ReturnAnyOfCommands(commands ...string) *SectionQuery
- func (s *SectionQuery) ReturnAnyOfFlags(flags ...string) *SectionQuery
- func (s *SectionQuery) ReturnAnyOfSlugs(slugs ...string) *SectionQuery
- func (s *SectionQuery) ReturnAnyOfTopics(topics ...string) *SectionQuery
- func (s *SectionQuery) ReturnApplications() *SectionQuery
- func (s *SectionQuery) ReturnExamples() *SectionQuery
- func (s *SectionQuery) ReturnOnlyCommands(commands ...string) *SectionQuery
- func (s *SectionQuery) ReturnOnlyFlags(flags ...string) *SectionQuery
- func (s *SectionQuery) ReturnOnlyNotShownByDefault() *SectionQuery
- func (s *SectionQuery) ReturnOnlyShownByDefault() *SectionQuery
- func (s *SectionQuery) ReturnOnlyTopLevel() *SectionQuery
- func (s *SectionQuery) ReturnOnlyTopics(topics ...string) *SectionQuery
- func (s *SectionQuery) ReturnTopics() *SectionQuery
- func (s *SectionQuery) ReturnTutorials() *SectionQuery
- func (s *SectionQuery) SearchForCommand(command string) *SectionQuery
- func (s *SectionQuery) SearchForSlug(slug string) *SectionQuery
- type SectionType
Constants ¶
const ( SectionGeneralTopic = model.SectionGeneralTopic SectionExample = model.SectionExample SectionApplication = model.SectionApplication SectionTutorial = model.SectionTutorial )
Variables ¶
var HELP_LIST_TEMPLATE string
var HELP_LONG_SECTION_TEMPLATE string
var HELP_SHORT_SECTION_TEMPLATE string
var HELP_SHORT_TOPIC_TEMPLATE string
var HELP_TOPIC_TEMPLATE string
var SectionTypeFromString = model.SectionTypeFromString
Re-export functions from model package
Functions ¶
func ExampleStoreUsage ¶ added in v0.5.53
func ExampleStoreUsage()
ExampleStoreUsage demonstrates how to use the new store-based query functionality
Types ¶
type HelpPage ¶
type HelpPage struct {
DefaultGeneralTopics []*Section
OtherGeneralTopics []*Section
// this is just the concatenation of default and others
AllGeneralTopics []*Section
DefaultExamples []*Section
OtherExamples []*Section
AllExamples []*Section
DefaultApplications []*Section
OtherApplications []*Section
AllApplications []*Section
DefaultTutorials []*Section
OtherTutorials []*Section
AllTutorials []*Section
}
HelpPage contains all the sections related to a command
func NewHelpPage ¶
type HelpSystem ¶
func NewHelpSystem ¶
func NewHelpSystem() *HelpSystem
func NewHelpSystemWithStore ¶ added in v0.5.53
func NewHelpSystemWithStore(st *store.Store) *HelpSystem
NewHelpSystemWithStore creates a HelpSystem with store backend support
func (*HelpSystem) AddSection ¶
func (hs *HelpSystem) AddSection(section *Section)
func (*HelpSystem) ComputeRenderData ¶
func (hs *HelpSystem) ComputeRenderData(userQuery *SectionQuery) (map[string]interface{}, bool)
func (*HelpSystem) GetSectionWithSlug ¶
func (hs *HelpSystem) GetSectionWithSlug(slug string) (*Section, error)
func (*HelpSystem) GetTopLevelHelpPage ¶
func (hs *HelpSystem) GetTopLevelHelpPage() *HelpPage
func (*HelpSystem) LoadSectionsFromFS ¶ added in v0.2.4
func (hs *HelpSystem) LoadSectionsFromFS(f fs.FS, dir string) error
func (*HelpSystem) PrintQueryDebug ¶ added in v0.5.53
func (hs *HelpSystem) PrintQueryDebug(queryDSL string, printQuery, printSQL bool) error
PrintQueryDebug prints debug information about a query
func (*HelpSystem) QuerySections ¶ added in v0.5.53
func (hs *HelpSystem) QuerySections(query string) ([]*Section, error)
QuerySections performs a DSL query on the current help system with boolean logic support
func (*HelpSystem) RenderTopicHelp ¶
func (hs *HelpSystem) RenderTopicHelp( topicSection *Section, options *RenderOptions) (string, error)
func (*HelpSystem) RenderTopicHelpWithWriter ¶ added in v0.7.1
func (hs *HelpSystem) RenderTopicHelpWithWriter( topicSection *Section, options *RenderOptions, output io.Writer, ) (string, error)
RenderTopicHelpWithWriter renders a topic's help content using the provided writer to detect terminal characteristics when applying Glamour styles.
type RenderOptions ¶
type Section ¶
type Section struct {
*model.Section
HelpSystem *HelpSystem
}
Section is a structure describing an actual documentation section.
This can describe:
- a general topic: think of this as an entry in a book
- an example: a way to run a certain command
- an application: a concrete use case for running a command. This can potentially use additional external tools, multiple commands, etc. While it is nice to keep these self-contained, it is not required.
- a tutorial: a step-by-step guide to running a command.
Run `glaze help help-system` for more information.
func LoadSectionFromMarkdown ¶
func (*Section) DefaultApplications ¶
func (*Section) DefaultExamples ¶
func (*Section) DefaultGeneralTopic ¶
func (*Section) DefaultTutorials ¶
func (*Section) IsForCommand ¶
func (*Section) IsForTopic ¶
func (*Section) OtherApplications ¶
func (*Section) OtherExamples ¶
func (*Section) OtherTutorials ¶
type SectionQuery ¶
type SectionQuery struct {
OnlyShownByDefault bool
OnlyNotShownByDefault bool
OnlyTopLevel bool
// only these types will be returned
Types map[SectionType]bool
// if any of these is set, and they match each of the Only types,
// the section will be return
Topics []string
Flags []string
Commands []string
Slugs []string
// this will return any section as long as it matches the Only strings
All bool
SearchedCommand string
SearchedSlug string
// a section will be returned only if it matches all
// of the following criteria
OnlyTopics []string
OnlyFlags []string
OnlyCommands []string
// We often need to filter sections that have already been shown
WithoutSections []*Section
}
SectionQuery represents a query to get different types of sections.
This is used for example by the `help` command line function to render out the help sections for individual commands.
It can however also be used on its own.
func NewSectionQuery ¶
func NewSectionQuery() *SectionQuery
func (*SectionQuery) Clone ¶
func (s *SectionQuery) Clone() *SectionQuery
func (*SectionQuery) DontReturnApplications ¶
func (s *SectionQuery) DontReturnApplications() *SectionQuery
func (*SectionQuery) DontReturnExamples ¶
func (s *SectionQuery) DontReturnExamples() *SectionQuery
func (*SectionQuery) DontReturnTopics ¶
func (s *SectionQuery) DontReturnTopics() *SectionQuery
func (*SectionQuery) DontReturnTutorials ¶
func (s *SectionQuery) DontReturnTutorials() *SectionQuery
func (*SectionQuery) FilterSections ¶
func (s *SectionQuery) FilterSections(sections ...*Section) *SectionQuery
func (*SectionQuery) FindSections ¶
FindSections queries sections using the store backend
func (*SectionQuery) GetOnlyQueryAsString ¶
func (s *SectionQuery) GetOnlyQueryAsString() string
func (*SectionQuery) GetRequestedTypesAsString ¶
func (s *SectionQuery) GetRequestedTypesAsString() string
func (*SectionQuery) HasOnlyQueries ¶
func (s *SectionQuery) HasOnlyQueries() bool
func (*SectionQuery) HasRestrictedReturnTypes ¶
func (s *SectionQuery) HasRestrictedReturnTypes() bool
func (*SectionQuery) IsOnlyTopLevel ¶
func (s *SectionQuery) IsOnlyTopLevel() bool
func (*SectionQuery) ResetOnlyQueries ¶
func (s *SectionQuery) ResetOnlyQueries() *SectionQuery
func (*SectionQuery) ReturnAllTypes ¶
func (s *SectionQuery) ReturnAllTypes() *SectionQuery
func (*SectionQuery) ReturnAnyOfCommands ¶
func (s *SectionQuery) ReturnAnyOfCommands(commands ...string) *SectionQuery
func (*SectionQuery) ReturnAnyOfFlags ¶
func (s *SectionQuery) ReturnAnyOfFlags(flags ...string) *SectionQuery
func (*SectionQuery) ReturnAnyOfSlugs ¶
func (s *SectionQuery) ReturnAnyOfSlugs(slugs ...string) *SectionQuery
func (*SectionQuery) ReturnAnyOfTopics ¶
func (s *SectionQuery) ReturnAnyOfTopics(topics ...string) *SectionQuery
func (*SectionQuery) ReturnApplications ¶
func (s *SectionQuery) ReturnApplications() *SectionQuery
func (*SectionQuery) ReturnExamples ¶
func (s *SectionQuery) ReturnExamples() *SectionQuery
func (*SectionQuery) ReturnOnlyCommands ¶
func (s *SectionQuery) ReturnOnlyCommands(commands ...string) *SectionQuery
func (*SectionQuery) ReturnOnlyFlags ¶
func (s *SectionQuery) ReturnOnlyFlags(flags ...string) *SectionQuery
func (*SectionQuery) ReturnOnlyNotShownByDefault ¶
func (s *SectionQuery) ReturnOnlyNotShownByDefault() *SectionQuery
func (*SectionQuery) ReturnOnlyShownByDefault ¶
func (s *SectionQuery) ReturnOnlyShownByDefault() *SectionQuery
func (*SectionQuery) ReturnOnlyTopLevel ¶
func (s *SectionQuery) ReturnOnlyTopLevel() *SectionQuery
func (*SectionQuery) ReturnOnlyTopics ¶
func (s *SectionQuery) ReturnOnlyTopics(topics ...string) *SectionQuery
func (*SectionQuery) ReturnTopics ¶
func (s *SectionQuery) ReturnTopics() *SectionQuery
func (*SectionQuery) ReturnTutorials ¶
func (s *SectionQuery) ReturnTutorials() *SectionQuery
func (*SectionQuery) SearchForCommand ¶
func (s *SectionQuery) SearchForCommand(command string) *SectionQuery
func (*SectionQuery) SearchForSlug ¶
func (s *SectionQuery) SearchForSlug(slug string) *SectionQuery
type SectionType ¶
type SectionType = model.SectionType
Re-export types from model package for backward compatibility