All Projects → growler → go-slate

growler / go-slate

Licence: MIT license
A CLI tool to generate API documentation using Slate layout by Robert Lord

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-slate

Slate
Beautiful static documentation for your API
Stars: ✭ 33,447 (+175936.84%)
Mutual labels:  static-site-generator, api-documentation, slate
node-slate
📓 Node.js port of lord/slate
Stars: ✭ 18 (-5.26%)
Mutual labels:  static-site-generator, api-documentation, slate
Api2html
A CLI tool to transform Swagger/OpenAPI/AsyncAPI docs to beautiful HTML pages via Shins/Widdershins.
Stars: ✭ 103 (+442.11%)
Mutual labels:  static-site-generator, api-documentation, slate
API-Portal
API Portal lets you create and publish a customized site with API documentation, for free and without writing any code.
Stars: ✭ 162 (+752.63%)
Mutual labels:  static-site-generator, api-documentation
reslate
Beautiful static documentation for your API
Stars: ✭ 98 (+415.79%)
Mutual labels:  static-site-generator, api-documentation
Hexo Theme Doc
A documentation theme for the Hexo blog framework
Stars: ✭ 222 (+1068.42%)
Mutual labels:  static-site-generator, api-documentation
Shins
Shins development continues at
Stars: ✭ 250 (+1215.79%)
Mutual labels:  static-site-generator, slate
webping
🚦 Python script to monitor web pages.
Stars: ✭ 20 (+5.26%)
Mutual labels:  static-site-generator
gridsome-starter-default
🐣 Default starter for Gridsome
Stars: ✭ 35 (+84.21%)
Mutual labels:  static-site-generator
protean
Evolve your RESTful API's and Web Services
Stars: ✭ 31 (+63.16%)
Mutual labels:  api-documentation
minipress
💁‍♂️ miniPress – a static site generator
Stars: ✭ 17 (-10.53%)
Mutual labels:  static-site-generator
restdocs-spec
A maven plugin for generating Open API and Postman Collection specifications using Spring Restdocs.
Stars: ✭ 43 (+126.32%)
Mutual labels:  api-documentation
laststaticsitegenerator
After learning how to use task runners like grunt, gulp, webpack and many static site generators i was in need for one workflow that makes setting up any tools unnecessary. Here it is!
Stars: ✭ 14 (-26.32%)
Mutual labels:  static-site-generator
gpp
General PreProcessor
Stars: ✭ 25 (+31.58%)
Mutual labels:  static-site-generator
polyglot
Create websites using any mix of programming languages or workflows 💎
Stars: ✭ 79 (+315.79%)
Mutual labels:  static-site-generator
potato-dark
Dark and elegant blog theme for goHugo static site generator.
Stars: ✭ 21 (+10.53%)
Mutual labels:  static-site-generator
mpa-frontend-template
🔥 Template based on webpack, pug, stylus, es6, postcss for multi page applications
Stars: ✭ 27 (+42.11%)
Mutual labels:  static-site-generator
csharp-docs-generator
An action that generates html documentation for C# programs to use for GitHub pages.
Stars: ✭ 21 (+10.53%)
Mutual labels:  api-documentation
pokedex-nextjs
Get to know the different render methods that the Next.js framework provides by exploring Pokemons
Stars: ✭ 39 (+105.26%)
Mutual labels:  static-site-generator
bowman
A simple static site generator with an integrated toolchain for efficient development and delivery.
Stars: ✭ 17 (-10.53%)
Mutual labels:  static-site-generator

go-slate

go-slate is a CLI tool to generate API documentation using brilliant Slate layout by Robert Lord. go-slate contains bundled Slate (including Kittn API Example Documentation) and requires no additional software to install.

go-slate can also generate a Go package with embedded documentation to include into Go binary. A simple HTTP(S) server to serve rendered documentation is also provided.

Why

Slate is arguably the best tool around to quickly hack an API documentation which will look really good. However it uses Ruby bundler and brings loads of software which did not go well with my Mac. Besides, I really got used to Go all you need is a single binary way of things.

There were also Hugo DocuAPI theme (based on Slate, too), but it has its own drawbacks, mostly because of different ways middleman and backfriday render contents.

So I quickly hacked go-slate.

Installation

$ go get -u github.com/growler/go-slate

How to start

Assuming following source tree

src
└── service
    ├── main.go
    └── apidoc

the typical usage would be:

  1. Extract template content
go-slate extract src/service/apidoc contents
  1. Now edit apidoc/index.html.md and add following lines to your main.go:
//go:generate go-slate package apidoc internal/apidoc

package main

import (
    "net/http"
    "fmt"
    "service/internal/apidoc"
)

func main() {
    http.HandleFunc("/help/", apidoc.HTTPHandlerWithPrefix("/help"))
    //...
    if err := http.ListenAndServe(":8080", nil); err != nil{
        fmt.Println(err)
    }
}
  1. Generate package with embedded documentation
go generate service
go build service
  1. Enjoy beautiful documentation at http://service:8080/help/

Usage

go-slate [command]

Available commands:

help        Help about any command
extract     extracts slate files bundled with go-slate to specified directory
package     produces an embeddable package with rendered documentation content and HTTP handler
site        renders documentation from source directory to output directory
server      serves rendered API documentation over HTTP(S)
version     prints version

Extact

go-slate extract [directory] [components to extract...]

Extracts Slate files bundled with go-slate to a specified directory. With none components supplied, extracts only slate example documentation project content (Markdown files). Otherwise, a specified list of components will be extracted. The component name might be either file name or one of

  • all
  • contents
  • layouts
  • stylesheets
  • javascripts
  • images

To list bundled Slate contents, use go-slate extract -l

Rendering commands options

Commands site, package and server render content and share a set of options

--no-minify css|jss|html|all

Disables compact output for a specific type of content. Multiple options can be listed with comma.

--logo

Defines a logo file to use, overriding default or setting in document preamble. Use word none to disable logo block completely.

--rtl and --no-rtl

Enables or disable Right-to-left scripts support, overriding default (no) or setting in document preamble.

--search and --no-search

Enables or disable Slate search block, overriding setting in document preamble.

--style file

Loads an SCSS style to adjust Slate styles. Note that this adds to, and not override document preamble option style. A list of available variables can be obtained by go-slate extract . stylesheets/_variables.scss

Site

go-slate site [source directory] [output directory] [flags]

Renders documentation to a destination.

Package

go-slate package [source directory] [resulting package directory] [flags]

Produces an embeddable Go package using go-imbed

--pkg name

By default, package takes package name from the last path item of resulting package directory. This option sets package name explicitly.

--work-dir directory

By default, package renders content in a temporary directory and removes it afterwards. This option tells go-slate to use specified directory and keep content afterwards.

Server

go-slate server [source directory] [address to listen at] [flags]

Starts an HTTP server listening at the specified address and serving rendered content.

--tls-cert file and --tls-key file

If both options are specified, server will serve HTTPS.

--monitor-changes

Monitor changes of source content and re-render if necessary. Any rendering error will be printed to stdout.

(A neat trick: go-slate server <empty directory> :8080 will serve the Slate example Kittn API Documentation)

Slate preamble options

go-slate supports Slate preamble options:

# document title
title: API Reference 

# must be one of supported by https://github.com/alecthomas/chroma
language_tabs: 
  - shell
  - ruby
  - python
  - javascript

# a list of footers to place under TOC navigation menu
toc_footers:  
  - <a href='#'>Sign Up for a Developer Key</a>
  - <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a>

# a list of files to include from includes directory.
# files must be named as includes/_<name>.md
includes:
  - errors

# enable search block
search: true 

In addition, go-slate defines a few others:

# a logo file to use. file must be located 
# in directory images. Use `none` to disable logo
logo: logo.png    

# enable RTL support
enable_rtl: true  

# use code highlight style, must be supported by  https://github.com/alecthomas/chroma
highlight_style: monokai

# plain html to add to html <head> _before_ all Slate stylesheets and javascripts references
html_premble: |
    <link rel="stylesheet" href="https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css">

# An SCSS header to adjust Slate CSS
# A list of available variables can be obtained by go-slate extract . stylesheets/_variables.scss
style: |
    %default-font {
      font-family: "Fira Code", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
      font-size: 14px;
    }
    

What go-slate is not

go-slate solves a very basic task and tries to be as simple and unobtrusive as possible. It is not, by any mean, a generic site generator. Use Hugo for that.

License

The MIT License, see LICENSE.md.

The embedded Slate is licensed under Apache 2.0 License, which can be extracted with go-slate extract . LICENSE command.

Special thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].