src

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2014 License: BSD-3-Clause, MIT Imports: 34 Imported by: 0

README

src

src is a command-line tool for automatically generating documentation and examples for your code and updating it on Sourcegraph.

Install

Download one of the pre-built binaries (TODO), or install from source:

$ go get sourcegraph.com/sourcegraph/srclib/cmd/src

Usage

To generate docs and examples for your code, go to your repository's top-level directory and run:

src make

The src make command first determines what needs to be done (e.g., by detecting the languages of the repository's code) and produces a Makefile that does the work. Then it executes the Makefile.

The output is written to /tmp/sg/github.com/USER/REPO/COMMITID (assuming your build dir is /tmp/sg). To display the output on Sourcegraph.com, so that people can browse documentation and examples online, run:

src push

In a few minutes, the latest documentation and examples will be visible on Sourcegraph.com.

(You can also run src push without running src make. In that case, all processing will occur on the Sourcegraph backend.)

Documentation

Index

Constants

View Source
const PersonSpecHelp = `Specify UIDs as '$n' (use \$n to shell-escape), as in '$123' for UID 123.`

Variables

View Source
var (
	Version   = "0.0.1"
	Name      = "srcgraph"
	ExtraHelp = ""
)
View Source
var CLI = flags.NewNamedParser("src", flags.Default)
View Source
var Subcommands = []Subcommand{}

Functions

func CloseAll

func CloseAll(files map[string]io.ReadCloser)

func Main

func Main()

func OpenInputFiles

func OpenInputFiles(extraArgs []string) map[string]io.ReadCloser

func PrintJSON

func PrintJSON(v interface{}, prefix string)

func SetOptionDefaultValue

func SetOptionDefaultValue(g *flags.Group, longName string, defaultVal ...string)

func SetRepoOptDefaults

func SetRepoOptDefaults(c *flags.Command)

func SourceUnitMatchesArgs

func SourceUnitMatchesArgs(specified []string, u *unit.SourceUnit) bool

Types

type APICmd

type APICmd struct{}

func (*APICmd) Execute

func (c *APICmd) Execute(args []string) error

type APIDescribeCmd

type APIDescribeCmd struct {
	File      string `long:"file" required:"yes" value-name:"FILE"`
	StartByte int    `long:"start-byte" required:"yes" value-name:"BYTE"`

	Examples bool `long:"examples" describe:"show examples from Sourcegraph.com"`
}

func (*APIDescribeCmd) Execute

func (c *APIDescribeCmd) Execute(args []string) error

type BuildCacheOpt

type BuildCacheOpt struct {
	NoCacheRead  bool `long:"no-cache-read" description:"do not read from build cache"`
	NoCacheWrite bool `long:"no-cache-write" description:"do not write results to build cache"`
}

type ConfigCmd

type ConfigCmd struct {
	config.Options

	ToolchainExecOpt `group:"execution"`
	BuildCacheOpt    `group:"build cache"`

	Output struct {
		Output string `short:"o" long:"output" description:"output format" default:"text" value-name:"text|json"`
	} `group:"output"`

	Args struct {
		Dir Directory `name:"DIR" default:"." description:"root directory of tree to configure"`
	} `positional-args:"yes"`
}

func (*ConfigCmd) Execute

func (c *ConfigCmd) Execute(args []string) error

type Directory

type Directory string

Directory is flags.Completer that provides directory name completion.

TODO(sqs): this is annoying. it only completes the dir name and doesn't let you keep typing the arg.

func (Directory) Complete

func (d Directory) Complete(match string) []flags.Completion

Complete implements flags.Completer and returns a list of existing directories with the given prefix.

type DoAllCmd

type DoAllCmd struct {
	config.Options

	ToolchainExecOpt `group:"execution"`
	BuildCacheOpt    `group:"build cache"`

	Dir Directory `short:"C" long:"directory" description:"change to DIR before doing anything" value-name:"DIR"`
}

func (*DoAllCmd) Execute

func (c *DoAllCmd) Execute(args []string) error

type InfoCmd

type InfoCmd struct{}

func (*InfoCmd) Execute

func (c *InfoCmd) Execute(args []string) error

type MakeCmd

type MakeCmd struct {
	config.Options

	ToolchainExecOpt `group:"execution"`
	BuildCacheOpt    `group:"build cache"`

	Dir Directory `short:"C" long:"directory" description:"change to DIR before doing anything" value-name:"DIR"`

	Args struct {
		Targets []string `name:"TARGETS..." description:"Makefile targets to build (default: all)"`
	} `positional-args:"yes"`
}

func (*MakeCmd) Execute

func (c *MakeCmd) Execute(args []string) error

type NormalizeGraphDataCmd

type NormalizeGraphDataCmd struct{}

func (*NormalizeGraphDataCmd) Execute

func (c *NormalizeGraphDataCmd) Execute(args []string) error

type PlanCmd

type PlanCmd struct {
	ToolchainExecOpt ToolchainExecOpt

	Args struct {
		Dir Directory `name:"DIR" default:"." description:"root directory of tree to plan"`
	} `positional-args:"yes"`
}

func (*PlanCmd) Execute

func (c *PlanCmd) Execute(args []string) error

type Repo

type Repo struct {
	RootDir  string // Root directory containing repository being analyzed
	VCSType  string // VCS type (git or hg)
	CommitID string // CommitID of current working directory
	CloneURL string // CloneURL of repo.
}

func OpenRepo

func OpenRepo(dir string) (*Repo, error)

func (*Repo) URI

func (c *Repo) URI() repo.URI

type Subcommand

type Subcommand struct {
	Name        string
	Description string
	Run         func(args []string)
}

type TestCmd

type TestCmd struct {
	GenerateExpected bool `long:"gen" description:"(re)generate expected output for all test cases and exit"`

	// ExeMethods is like the same field from ToolchainExecOpt, but we want it
	// to default to "docker" for tests. So, we have to redefine it here.
	ExeMethods string `` /* 169-byte string literal not displayed */

	Args struct {
		Trees []Directory `name:"TREES" description:"trees to treat as test cases"`
	} `positional-args:"yes"`
}

func (*TestCmd) Execute

func (c *TestCmd) Execute(args []string) error

type ToolCmd

type ToolCmd struct {
	ToolchainExecOpt

	Args struct {
		Toolchain ToolchainPath `name:"TOOLCHAIN" description:"toolchain path of the toolchain to run"`
		Tool      ToolName      `name:"TOOL" description:"tool subcommand name to run (in TOOLCHAIN)"`
		ToolArgs  []string      `name:"ARGS" description:"args to pass to TOOL"`
	} `positional-args:"yes" required:"yes"`
}

func (*ToolCmd) Execute

func (c *ToolCmd) Execute(args []string) error

type ToolName

type ToolName string

func (ToolName) Complete

func (t ToolName) Complete(match string) []flags.Completion

type ToolchainAddCmd added in v0.0.3

type ToolchainAddCmd struct {
	Dir  string `long:"dir" description:"directory containing toolchain to add" value-name:"DIR"`
	Args struct {
		ToolchainPath string `name:"TOOLCHAIN" default:"." description:"toolchain path to use for toolchain directory"`
	} `positional-args:"yes" required:"yes"`
}

func (*ToolchainAddCmd) Execute added in v0.0.3

func (c *ToolchainAddCmd) Execute(args []string) error

type ToolchainBuildCmd

type ToolchainBuildCmd struct {
	Args struct {
		Toolchains []ToolchainPath `name:"TOOLCHAINS" description:"toolchain paths of toolchains to build"`
	} `positional-args:"yes" required:"yes"`
}

func (*ToolchainBuildCmd) Execute

func (c *ToolchainBuildCmd) Execute(args []string) error

type ToolchainCmd

type ToolchainCmd struct{}

func (*ToolchainCmd) Execute

func (c *ToolchainCmd) Execute(args []string) error

type ToolchainExecOpt

type ToolchainExecOpt struct {
	ExeMethods string `short:"m" long:"methods" default:"program,docker" description:"permitted execution methods" value-name:"METHODS"`
}

func (*ToolchainExecOpt) ToolchainMode

func (o *ToolchainExecOpt) ToolchainMode() toolchain.Mode

type ToolchainGetCmd

type ToolchainGetCmd struct {
	Args struct {
		Toolchains []ToolchainPath `name:"TOOLCHAINS" description:"toolchain paths of toolchains to get"`
	} `positional-args:"yes" required:"yes"`
}

func (*ToolchainGetCmd) Execute

func (c *ToolchainGetCmd) Execute(args []string) error

type ToolchainListCmd

type ToolchainListCmd struct {
}

func (*ToolchainListCmd) Execute

func (c *ToolchainListCmd) Execute(args []string) error

type ToolchainListToolsCmd

type ToolchainListToolsCmd struct {
	Op             string `short:"p" long:"op" description:"only list tools that perform these operations only" value-name:"OP"`
	SourceUnitType string `short:"u" long:"source-unit-type" description:"only list tools that operate on this source unit type" value-name:"TYPE"`
	Args           struct {
		Toolchains []ToolchainPath `name:"TOOLCHAINS" description:"only list tools in these toolchains"`
	} `positional-args:"yes" required:"yes"`
}

func (*ToolchainListToolsCmd) Execute

func (c *ToolchainListToolsCmd) Execute(args []string) error

type ToolchainPath

type ToolchainPath string

func (ToolchainPath) Complete

func (t ToolchainPath) Complete(match string) []flags.Completion

type UnitsCmd

type UnitsCmd struct {
	config.Options

	ToolchainExecOpt `group:"execution"`

	Output struct {
		Output string `short:"o" long:"output" description:"output format" default:"text" value-name:"text|json"`
	} `group:"output"`

	Args struct {
		Dir Directory `name:"DIR" default:"." description:"root directory of tree to list units in"`
	} `positional-args:"yes"`
}

func (*UnitsCmd) Execute

func (c *UnitsCmd) Execute(args []string) error

Jump to

Keyboard shortcuts

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