Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
Problem: Gosh packages are not documented.
Browse files Browse the repository at this point in the history
Solution: create doc.go stubs.
  • Loading branch information
AlekSi committed Nov 7, 2018
1 parent 3877da6 commit f05ac68
Show file tree
Hide file tree
Showing 33 changed files with 130 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Gosh

[![GoDoc](https://godoc.org/gosh-lang.org/gosh?status.svg)](https://godoc.org/gosh-lang.org/gosh)
[![Travis CI Build Status](https://travis-ci.org/gosh-lang/gosh.svg?branch=master)](https://travis-ci.org/gosh-lang/gosh)
[![Code Coverage](https://codecov.io/gh/gosh-lang/gosh/branch/master/graph/badge.svg)](https://codecov.io/gh/gosh-lang/gosh)
[![Go Report Card](https://goreportcard.com/badge/gosh-lang.org/gosh)](https://goreportcard.com/report/gosh-lang.org/gosh)
Expand Down
3 changes: 1 addition & 2 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package ast declares the types used to represent syntax trees for Gosh packages.
package ast // import "gosh-lang.org/gosh/ast"
package ast

import (
"fmt"
Expand Down
9 changes: 9 additions & 0 deletions ast/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package ast declares the types used to represent syntax trees for Gosh packages.
package ast // import "gosh-lang.org/gosh/ast"
2 changes: 1 addition & 1 deletion ast/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package ast // import "gosh-lang.org/gosh/ast"
package ast

import (
"strings"
Expand Down
2 changes: 1 addition & 1 deletion ast/statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package ast // import "gosh-lang.org/gosh/ast"
package ast

import (
"strings"
Expand Down
2 changes: 1 addition & 1 deletion internal/gofuzz/corpus.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package gofuzz // import "gosh-lang.org/gosh/internal/gofuzz"
package gofuzz

import (
"crypto/sha1" //nolint:gosec // go-fuzz uses SHA1 for non-cryptographic hashing
Expand Down
2 changes: 1 addition & 1 deletion internal/golden/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package golden // import "gosh-lang.org/gosh/internal/golden"
package golden

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion interpreter/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package interpreter // import "gosh-lang.org/gosh/interpreter"
package interpreter

import (
"context"
Expand Down
9 changes: 9 additions & 0 deletions interpreter/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package interpreter implements Gosh interpreter.
package interpreter // import "gosh-lang.org/gosh/interpreter"
2 changes: 1 addition & 1 deletion interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package interpreter // import "gosh-lang.org/gosh/interpreter"
package interpreter

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion interpreter/interpreter_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// +build gofuzz

package interpreter // import "gosh-lang.org/gosh/interpreter"
package interpreter

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion interpreter/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package interpreter // import "gosh-lang.org/gosh/interpreter"
package interpreter

import (
"bytes"
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package main
// Package gosh implements gosh command.
// * https://godoc.org/gosh-lang.org/gosh/tokens
// * https://godoc.org/gosh-lang.org/gosh/scanner
// * https://godoc.org/gosh-lang.org/gosh/ast
// * https://godoc.org/gosh-lang.org/gosh/parser
// * https://godoc.org/gosh-lang.org/gosh/objects
// * https://godoc.org/gosh-lang.org/gosh/interpreter
package main // import "gosh-lang.org/gosh"

import (
"context"
Expand Down
43 changes: 43 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package main

import (
"context"
"fmt"
"log"
"os"

"gosh-lang.org/gosh/interpreter"
"gosh-lang.org/gosh/objects"
"gosh-lang.org/gosh/parser"
"gosh-lang.org/gosh/scanner"
)

func Example() {
code := `println("Hello, world!")`

s, err := scanner.New(code, nil)
if err != nil {
log.Fatal(err)
}

p := parser.New(s, nil)
program := p.ParseProgram()
if p.Errors() != nil {
log.Fatal(p.Errors())
}

i := interpreter.New(nil)
scope := objects.NewScope(objects.Builtin(os.Stdout))
res := i.Eval(context.Background(), program, scope)
fmt.Println("Eval result:", res)
// Output:
// Hello, world!
// Eval result: <nil>
}
1 change: 1 addition & 0 deletions misc/check_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// +build ignore

// check_license checks that MPL license header in all files matches header in this file.

package main

import (
Expand Down
1 change: 1 addition & 0 deletions misc/run_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// +build ignore

// run_fuzzer runs go-fuzz for the given package.

package main

import (
Expand Down
2 changes: 1 addition & 1 deletion objects/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package objects // import "gosh-lang.org/gosh/objects"
package objects

import (
"fmt"
Expand Down
9 changes: 9 additions & 0 deletions objects/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package objects declares the types used to represent runtime Gosh objects.
package objects // import "gosh-lang.org/gosh/objects"
2 changes: 1 addition & 1 deletion objects/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package objects // import "gosh-lang.org/gosh/objects"
package objects

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion objects/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package objects // import "gosh-lang.org/gosh/objects"
package objects

// A Scope maintains the set of named language entities declared in the scope
// and a link to the immediately surrounding (outer) scope.
Expand Down
2 changes: 1 addition & 1 deletion objects/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package objects // import "gosh-lang.org/gosh/objects"
package objects

//go:generate stringer -type Type

Expand Down
9 changes: 9 additions & 0 deletions parser/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package parser implements a parser for Gosh source files.
package parser // import "gosh-lang.org/gosh/parser"
2 changes: 1 addition & 1 deletion parser/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package parser // import "gosh-lang.org/gosh/parser"
package parser

// Error is a parser error.
type Error struct {
Expand Down
3 changes: 1 addition & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package parser implements a parser for Gosh source files.
package parser // import "gosh-lang.org/gosh/parser"
package parser

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion parser/parser_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// +build gofuzz

package parser // import "gosh-lang.org/gosh/parser"
package parser

import (
"gosh-lang.org/gosh/scanner"
Expand Down
2 changes: 1 addition & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package parser // import "gosh-lang.org/gosh/parser"
package parser

import (
"strings"
Expand Down
9 changes: 9 additions & 0 deletions scanner/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package scanner implements a scanner for Gosh source text.
package scanner // import "gosh-lang.org/gosh/scanner"
3 changes: 1 addition & 2 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package scanner implements a scanner for Gosh source text.
package scanner // import "gosh-lang.org/gosh/scanner"
package scanner

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion scanner/scanner_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// +build gofuzz

package scanner // import "gosh-lang.org/gosh/scanner"
package scanner

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package scanner // import "gosh-lang.org/gosh/scanner"
package scanner

import (
"strings"
Expand Down
9 changes: 9 additions & 0 deletions tokens/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Gosh programming language.
// Copyright (c) 2018 Alexey Palazhchenko and contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package tokens declares constants representing the lexical tokens of the Gosh programming language.
package tokens // import "gosh-lang.org/gosh/tokens"
3 changes: 1 addition & 2 deletions tokens/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package tokens defines constants representing the lexical tokens of the Gosh programming language.
package tokens // import "gosh-lang.org/gosh/tokens"
package tokens

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion tokens/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package tokens // import "gosh-lang.org/gosh/tokens"
package tokens

import (
"fmt"
Expand Down

0 comments on commit f05ac68

Please sign in to comment.