Giter VIP home page Giter VIP logo

docserv's Introduction

docserv

docserv is a Golang package that you can integrate into your project to generate a documentation browser. See godoc for more information.

It has two modes; reading the documents from filesystem or generating static copies with go-bindata

Install

go get -u github.com/gerbenjacobs/docserv

If you plan on using the static abilities, also make sure to install go-bindata.

go get -u github.com/jteeuwen/go-bindata/...

Usage

Filesystem mode

ds := docserv.NewDocServ([]string{"README.md"})
ds.Run()

Static mode

./static.sh [filepath]...

The above script will convert your documents to a go-bindata Go script that will imitate a local filesystem when you compile your original program.

You can copy this script to your project (you can change the package name and output file) and use it. Make sure to import this package.

import path/to/static

ds := docserv.NewStaticDocServ(map[string][]byte{"README.md": static.MustAsset("README.md")})
ds.Run()

Config

type DocServConfig struct {
	Endpoint        string   // Endpoint to listen to (default: /docs)
	UseStatic       bool     // Whether to use Static mode (default: false)
	Docs            []string // The filepaths for documentation
	Host            string   // The host part of the HTTP listener (default: "")
	Port            string   // The port part of the HTTP listener (default: 9000)
	UseHighlighting bool     // Whether to use syntax highlighting (default: true)
	SyntaxStyle     string   // The style to use for syntax highlighting (default: darkula)
}

Template

screenshot

DocServ comes with a default template in resources/template.html. You can change this template if you wish.

It is using go-bindata so you can run the build.sh script.

Syntax Highlighting

We are using highlight.js to add syntax highlighting to your documents.

If you want you can set the SyntaxStyle in the DocServeConfig to any string that will match any of the styles showcased here and hosted here (Note: Lowercase and spaces replaced with dashes)

docserv's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.