Giter Club home page Giter Club logo

Comments (4)

retronav avatar retronav commented on May 30, 2024 2

Cobra includes command generation. Here are the docs:
https://github.com/spf13/cobra/blob/master/doc/README.md
https://github.com/spf13/cobra/blob/master/doc/md_docs.md

I will definitely play with that a bit and get back here!

from timetrace.

retronav avatar retronav commented on May 30, 2024 2

I tried generating some docs, and it works:

Generated docs:

  1. Index documentation
    image

  2. Document of a command
    image

  3. Documentation of a subcommand
    image

Steps to generate documentation

  1. Create a script file (in a separate directory)
  2. Paste the main function from main.go, but with some modifications
package main

import (
	"log"

	"github.com/dominikbraun/timetrace/cli"
	"github.com/dominikbraun/timetrace/config"
	"github.com/dominikbraun/timetrace/core"
	"github.com/dominikbraun/timetrace/fs"
	"github.com/dominikbraun/timetrace/out"
	"github.com/spf13/cobra/doc"
)

var version = "UNDEFINED"

func main() {
	c, err := config.FromFile()
	if err != nil {
		out.Warn("%s", err.Error())
	}

	filesystem := fs.New(c)
	timetrace := core.New(c, filesystem)

	cmd := cli.RootCommand(timetrace, version)
	err = doc.GenMarkdownTree(cmd, "./docs")
	if err != nil {
		log.Fatal(err)
	}
}
  1. Running that script with go run places docs in the docs directory in cwd

This was the process. We can incorporate it in CI with a bit of refining. @dominikbraun Any suggestions?

from timetrace.

dominikbraun avatar dominikbraun commented on May 30, 2024 1

Wow, thanks! This looks exactly like what I've been looking for. I'm going to open some issues for implementing this 😄

from timetrace.

dominikbraun avatar dominikbraun commented on May 30, 2024

I'm going to close this since we found a way to auto-generate docs. The subsequent issue is #87. Thanks again for figuring this out!

from timetrace.

Related Issues (20)

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.