sherpago

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 8 Imported by: 0

README

Sherpago

Sherpago reads the (machine-readable) documentation for a sherpa API as generated by sherpadoc, and outputs a documented Go package with a client with all functions and types from the sherpa documentation. Example:

# Fetch the API description as sherpadoc.
# The author of the API probably used "sherpadoc MyAPI" to generate this documentation.
curl https://example.org/myapi/_docs >myapi.json

# Turn the sherpadoc into a Go client library.
sherpago MyAPI https://example.org/myapi/ < myapi.json > myapi.go
gofmt -w myapi.go

Read the sherpago documentation at godoc.org/github.com/mjl-/sherpago.

Info

Written by Mechiel Lukkien, mechiel@ueber.net, feedback welcome. MIT-licensed, contains 3-clause BSD licensed code from github.com/golang/lint.

TODO

  • check if identifiers (type names, function names) are keywords in go. if so, rename them so they are not, and don't clash with existing names.

  • write tests, both for library and generated code

  • think about adding helper for dealing with errors. eg whether it is a sherpa, server or user error.

  • either return error message or use another name when we get duplicate identifiers (type or field or function names) after turning a name from sherpadoc into a proper Go identifier. currently we generate Go code that won't compile.

  • reformat comments, turning markdown from sherpadoc into more readable Go comments. e.g. turn bullet lists into indented wrapped text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate added in v0.0.2

func Generate(in io.Reader, out io.Writer, packageName, baseURL string) (retErr error)

Generate reads sherpadoc from in and writes a Go file containing a client package to out. It requires two parameters: the package name to use and the baseURL for the API.

Types

This section is empty.

Directories

Path Synopsis
cmd
sherpago
Command sherpago reads documentation from a sherpa API ("sherpadoc") and outputs a documented Go package that exports all functions and types referenced in that machine-readable documentation.
Command sherpago reads documentation from a sherpa API ("sherpadoc") and outputs a documented Go package that exports all functions and types referenced in that machine-readable documentation.

Jump to

Keyboard shortcuts

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