This subrepository holds a POC for generating YAML format of GoLang API DOC, leveraging the godoc functions.
Accepts a package name and the directory containing its source codes Generates a YAML file containing the entity(Variables, Constants, Functions, Types) and its corresponding document
- Ensure that you have installed godoc, yaml.v2 packages, otherwise use go get to install packages.
- Go to the root folder and run "go build main.go" to build.
- Run "main [source package path] [source package name] [output folder]", for example "main C:/Go/src fmt C:/result/", C:/Go/src is the source package path, fmt is the package name, output fodler is C:/result/, after the command finished, you can see the fmt.yml in the result folder.
-
All documents are generated in a single YAML file
further requirement of seperating documents by types should be supported -
Current ast.Node for golang entity(Variables, Constants, Functions, Types) is directly printed via go/printer
the format is not friendly(contains \n,\t .etc) and this contains source code details
Format refinement, source code hiding, document seperation should be supported
If finer manipulation of golang entity needed, kind of AST walker may need to be implemented. In that case, can refer to https://github.com/nirasan/ast-walker/blob/master/lib/walk.go