go/pkg/help/README.md
Snider 4e02d5bc97 refactor: bring external packages home and restructure
- Imported packages from separate repos:
  - github.com/Snider/config -> pkg/config
  - github.com/Snider/display -> pkg/display
  - github.com/Snider/help -> pkg/help
  - github.com/Snider/i18n -> pkg/i18n
  - github.com/Snider/updater -> pkg/updater
- Moved core code from root to pkg/core
- Flattened nested package structures
- Updated all import paths to github.com/Snider/Core/pkg/*
- Added Display interface to Core
- Updated go.work for workspace modules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 15:30:43 +00:00

2.9 KiB

Help Module

Go Reference Go Report Card Codecov Build Status License: EUPL-1.2

This repository contains the help module, which was formerly part of the Snider/Core framework. This module provides assistance and documentation functionality.

Getting Started

This project uses mkdocs-material to build the documentation. To get started, you will need to have Python and pip installed.

  1. Install the dependencies:

    pip install -r requirements.txt
    
  2. Run the development server:

    mkdocs serve
    

Usage

To use the help module, you first need to import it in your Go project:

import "github.com/Snider/help"

Next, initialize the help service by calling the New function. The New function accepts an Options struct, which allows you to configure the documentation source.

Using a custom embed.FS

You can provide your own embed.FS as a documentation source. This is useful when you want to bundle the documentation with your application.

import (
    "embed"
    "github.com/Snider/help"
)

//go:embed all:my-docs/build
var myDocs embed.FS

func main() {
    helpService, err := help.New(help.Options{
        Assets: myDocs,
    })
    if err != nil {
        // Handle error
    }
    // ...
}

Custom Static Site Source

You can also provide a custom directory containing a static website as the documentation source. To do this, set the Source field in the Options struct to the path of your static site directory:

helpService, err := help.New(help.Options{
    Source: "path/to/your/static/site",
})
if err != nil {
    // Handle error
}

Once the help service is initialized, you can use the Show() and ShowAt() methods to display the documentation.

Displaying Help

The Show() method opens the help window to the main page.

err := helpService.Show()
if err != nil {
    // Handle error
}

The ShowAt() method opens the help window to a specific anchor. The provided anchor is normalized into a URL. For example, calling ShowAt("ui/how/settings#resetPassword") will open the help window to a URL similar to http://localhost:8080/docs/ui/how/settings/index.html#resetPassword. The exact URL depends on how your display service resolves these paths.

err := helpService.ShowAt("ui/how/settings#resetPassword")
if err != nil {
    // Handle error
}