예제 #1
0
func godoc(member, content string) string {
	undocumented := "// " + exportable(member) + " is undocumented.\n"

	node, err := html.Parse(strings.NewReader(content))
	if err != nil {
		return undocumented
	}

	_, v, err := sandblast.Extract(node)
	if err != nil {
		return undocumented
	}

	v = strings.TrimSpace(v)
	if v == "" {
		return undocumented
	}

	if member != "" {
		v = exportable(member) + " " + strings.ToLower(v[0:1]) + v[1:]
	}

	out := bytes.NewBuffer(nil)
	doc.ToText(out, v, "// ", "", 72)
	return out.String()
}
예제 #2
0
func godoc(name, helpText string, indent string) string {
	node, err := html.Parse(strings.NewReader(helpText))
	if err != nil {
		return "no documentation"
	}

	_, helpText, err = sandblast.Extract(node)
	if err != nil {
		return "no documentation"
	}

	helpText = strings.TrimSpace(helpText)
	if helpText == "" {
		helpText = "no documentation"
	}

	text := upper(name) + " - " + helpText
	out := bytes.NewBuffer(nil)
	doc.ToText(out, text, indent+"// ", "", 100)
	return out.String()
}