godoc-repair

command module
v0.0.0-...-9a99005 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 15 Imported by: 0

README

godoc-generate

Go Report Card

Overview

godoc-repair is forked from DimitarPetrov/godoc-generate

godoc-repair is a simple command line tool that repairs godoc comments and generates default godoc comments on all exported types, functions, consts and vars in the specified directory and recursively for all subdirectories.

Explain

  • It is necessary to write comments well.
  • Tool will only fix some types of comments.
  • It is recommended to check the comments after repaired.

Types

The following comments will be fixed, include type/func/const/var:

missing name

before repair

// camel case
type CamelCase struct {
}

after repair

// CamelCase camel case
type CamelCase struct {
}
with a colon

before repair

// CamelCase: camel case
type CamelCase struct {
}

//CamelCase2: camel case
type CamelCase2 struct {
}

after repair

// CamelCase camel case
type CamelCase struct {
}

// CamelCase2 camel case
type CamelCase2 struct {
}
missing comment

The repaired godoc comments looks like this:

// %s missing godoc.

Where %s is the name of the type/func/const/var.

NOTE: The comment format can be overridden via the --format flag.

before repair

type CamelCase struct {
}

after repair

// CamelCase missing godoc.
type CamelCase struct {
}

go-repair will add automatically comment description if enable auto description.

before repair

type CamelCase struct {
}

after repair

// CamelCase camel case
type CamelCase struct {
}
missing description

As default.

before repair

// CamelCase
type CamelCase struct {
}

//CamelCase2
type CamelCase2 struct {
}

after repair

// CamelCase missing godoc. 
type CamelCase struct {
}

// CamelCase2 missing godoc.
type CamelCase2 struct {
}

The same to "missing comment", it will add automatically comment description if enable auto description.

before repair

// CamelCase
type CamelCase struct {
}

//CamelCase2
type CamelCase2 struct {
}

after repair

// CamelCase camel case
type CamelCase struct {
}

// CamelCase2 camel case
type CamelCase2 struct {
}

Installation

Installing from Source
go install github.com/xiaoyuanhao/godoc-repair
Usage

After installed, use the command to repair.

go-repair --code-path /path/to/your/code
// example: go-repair --code-path ./example --auto-description

support flag:

  • --format, overwrite the default comment format.
  • --code-path, code path needs to be repaired, default is the current working directory.
  • --auto-description, set comment description with function name.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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