doc

package
v0.0.0-...-0e7933b Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package doc extracts source code documentation from a Magpie AST.

Index

Constants

This section is empty.

Variables

View Source
var (

	//PlaceHolder line, used only in html output.
	PlaceHolderTOC           = "<p>__TOC_PLACEHOLDER_LINE_END__</p>"
	PlaceHolderShowSourceEnd = "<p>__SHOWSOURCE_PLACEHOLDER_LINE_END__</p>"

	Cfg = Config{}
)
View Source
var (
	//Predefined css style color
	BuiltinCssStyle = map[int][]string{
		0: []string{"black", "#f7f7f7", "#969896", "#795da3", "#333", "#a71d5d", "#333", "#333"},
		1: []string{"#dcdcdc", "#3f3f3f", "#7f9f7f", "#efef8f", "#efef8f", "#e3ceab", "#efef8f", "#efef8f"},
		2: []string{"#695d69", "#f7f3f7", "#379a37", "#776977", "#776977", "#7b59c0", "#776977", "#776977"},
		3: []string{"#5e6e5e", "#f0fff0", "#379a37", "#40a070", "#776977", "#ad2bee", "#776977", "#776977"},
		4: []string{"#5e6e5e", "#fbebd4", "#379a37", "#40a070", "#a57a4c", "#ad2bee", "#a57a4c", "#a57a4c"},
		5: []string{"#0ff", "navy", "#888", "#ff0", "#fff", "#fff", "#a57a4c", "#a57a4c"},
		6: []string{"#bbbb9d", "#282c34", "#969896", "#51b6c2", "#7cc379", "#c678dd", "#333", "#333"},
		7: []string{"#51616b", "#f2fbff", "grey", "green", "#008bb7", "#e68538", "#333", "#333"},
	}
)

Functions

func HtmlDocGen

func HtmlDocGen(content string, file *File) string

HtmlDocGen generates html documentation from a markdown file.

func MdDocGen

func MdDocGen(f *File) string

MdDocGen generates markdown documentation from doc.File.

func SanitizedAnchorName

func SanitizedAnchorName(text string) string

SanitizedAnchorName returns a sanitized anchor name for the given text. copied from 'Blackfriday': a markdown processor for Go.

Types

type Classes

type Classes struct {
	Value *Value
	Props []*Value    //Properties
	Lets  []*Value    //Let-statements
	Funcs []*Function //Function
}

Classes is the documention for a class

type Config

type Config struct {
	ShowSrcComment int    //1:if show source comment
	GenHTML        int    //1: if generate html-style document
	CssStyle       int    // default css style to use.(See css.go for builtin css styles)
	CssContents    string //User supplied css file contents for styling generated html file
}

type File

type File struct {
	Name    string //FileName
	Classes []*Classes
	Enums   []*Value
	Lets    []*Value
	Consts  []*Value
	Funcs   []*Function
	GenHTML int
}

File is the documentation for an entire magpie file.

func New

func New(name string, program *ast.Program) *File

type FuncInfo

type FuncInfo struct {
	Name string //parameter name if @param, or else ""
	Type string //type
	Desc string //description
}

function information(@param/@return/@returns part)

type Function

type Function struct {
	Value   *Value
	Params  []*FuncInfo
	Returns []*FuncInfo
}

Classes is the documention for a function

type Request

type Request struct {
	Text    string `json:"text"`
	Mode    string `json:"mode"`
	Context string `json:"context"`
}

Request for github REST API URL : https://developer.github.com/v3/markdown/

type Value

type Value struct {
	Name string //name
	Doc  string //comment
	Text string //declaration text

	ShowSrc  int    //should source or not, 1: show
	Src      string //Source code text
	SrcLines int    //number of lines of `Src`.
	GenHTML  int    //1: if generate html-style document
}

Value is the documentation for a (possibly grouped) enums, lets, functions, or class declaration.

Jump to

Keyboard shortcuts

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