cpdocs2impl

package module
v0.0.0-...-2c5eb60 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2018 License: MIT Imports: 9 Imported by: 0

README

cpdocs2impl

cpdocs2impl is used to copy method comments from Go interfaces to implementations. It can replace existing comments, or only add missing comments.

Install

go get -u github.com/tzneal/cpdocs2impl/cmd/cpdocs2impl

Usage

Usage: ./cpdocs2impl [OPTION]... [PACKAGE]...
Copy docs from interfaces to implementations
  -imports
    	consider interfaces from imports as well (slower)
  -replace
    	replace any existing documentation

cpdocs2iml uses the common technique of unnamed variable declarations that ensure an implementation implements an interface to identify cases where documentation should be copied from an interface to an implementation. As an example it can modify source from:

package testdata

type Fooer interface {
	// Foo does some foo stuff
	Foo()
	// Bar is different
	Bar()
}

var _ Fooer = (*Concrete)(nil)

type Concrete struct {
}

func (c *Concrete) Foo() {}
func (c *Concrete) Bar() {}

into this:

package testdata

type Fooer interface {
	// Foo does some foo stuff
	Foo()
	// Bar is different
	Bar()
}

var _ Fooer = (*Concrete)(nil)

type Concrete struct {
}


// Foo does some foo stuff
func (c *Concrete) Foo() {} 
// Bar is different
func (c *Concrete) Bar() {}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentCollector

type CommentCollector struct {
	// If set, RewriteFn will be called for files that need to be rewritten (used for unit test)
	RewriteFn func(filename string, fset *token.FileSet, file *ast.File)
	// contains filtered or unexported fields
}

func NewCommentCollector

func NewCommentCollector(processImports bool, replaceComments bool) *CommentCollector

func (*CommentCollector) Process

func (c *CommentCollector) Process(pkgs []*packages.Package)

Directories

Path Synopsis
cmd
cpdocs2impl command

Jump to

Keyboard shortcuts

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