codoc

package module
v0.0.0-...-7194fc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: MIT Imports: 1 Imported by: 2

README

codoc

GoDoc

Extract Go package documentation to be used at runtime.

Usage

To generate a documentation file for a Go package, run the following command:

go run github.com/noonien/codoc/cmd/codoc@latest -pkg main -out example_doc.go ./example

This will generate an example_doc.go file that registers the package documentation with the codoc package. Assuming the example_doc.go file is imported somewhere by your program, the documentation can be accessed like so:

package main

import (
    "github.com/noonien/codoc"

    // make sure example_doc.go is part of, or imported by your program
)

func main() {
    pkg := codoc.Package("main")      // Get documentation for the main package
    fn := codoc.Function("main.Foo")  // Get documentation for the function Foo in the main package
    st := codoc.Struct("main.Bar")    // Get documentation for the struct Bar in the main package

    // Example usage
    fmt.Println(pkg)
    fmt.Println(fn)
    fmt.Println(st)
}

License

codoc is released under the MIT License. See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(pkg Package)

Types

type Field

type Field struct {
	Name    string
	Doc     string
	Comment string
}

type Function

type Function struct {
	Name    string
	Doc     string
	Args    []string
	Results []string
}

func GetFunction

func GetFunction(id string) *Function

type Package

type Package struct {
	ID        string
	Name      string
	Doc       string
	Functions map[string]Function
	Structs   map[string]Struct
}

func GetPackage

func GetPackage(id string) *Package

type Struct

type Struct struct {
	Name    string
	Doc     string
	Fields  map[string]Field
	Methods map[string]Function
}

func GetStruct

func GetStruct(id string) *Struct

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL