Skip to content

Commit

Permalink
move document package from internal to pkg (#588)
Browse files Browse the repository at this point in the history
The purpose of this PR is to make it possible to reuse runme's Markdown
-> Notebook code.
In particular I'd like to use it to parse ChatGPT output into a notebook
so that code blocks can be rendered in RunMe notebooks.

In Foyle, there is currently a bug with parsing out code blocks nested
inside lists jlewi/foyle#114. Runme's code properly handles this use
case. This will allow us to reuse RunMe's code to fix this problem.
  • Loading branch information
jlewi authored May 24, 2024
1 parent 7d1c469 commit 6d103ae
Show file tree
Hide file tree
Showing 40 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/beta/run_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/stateful/runme/v3/internal/command"
"github.com/stateful/runme/v3/internal/config/autoconfig"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/project"
"github.com/stateful/runme/v3/pkg/document"
)

func runCmd(*commonFlags) *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/internal/project"
"github.com/stateful/runme/v3/internal/runner/client"
"github.com/stateful/runme/v3/internal/tui"
"github.com/stateful/runme/v3/internal/tui/prompt"
runnerv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v1"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/identity"
)

const envStackDepth = "__RUNME_STACK_DEPTH"
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/editor"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/internal/renderer/cmark"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/editor"
"github.com/stateful/runme/v3/pkg/document/identity"
)

func fmtCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/stateful/runme/v3/internal/command"
"github.com/stateful/runme/v3/internal/config"
"github.com/stateful/runme/v3/internal/document/editor/editorservice"
"github.com/stateful/runme/v3/internal/project/projectservice"
"github.com/stateful/runme/v3/internal/runner"
runnerv2service "github.com/stateful/runme/v3/internal/runnerv2service"
Expand All @@ -24,6 +23,7 @@ import (
projectv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/project/v1"
runnerv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v1"
runnerv2alpha1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v2alpha1"
"github.com/stateful/runme/v3/pkg/document/editor/editorservice"
)

func serverCmd() *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions internal/command/command_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"go.uber.org/zap/zaptest"

"github.com/stateful/runme/v3/internal/config"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/identity"
runnerv2alpha1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v2alpha1"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/identity"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/config_code_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path/filepath"
"strings"

"github.com/stateful/runme/v3/internal/document"
runnerv2alpha1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v2alpha1"
"github.com/stateful/runme/v3/pkg/document"
)

func NewProgramConfigFromCodeBlock(block *document.CodeBlock) (*ProgramConfig, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/stateful/godotenv"
"go.uber.org/zap"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/identity"
)

type LoadEventType uint8
Expand Down
2 changes: 1 addition & 1 deletion internal/project/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/pkg/errors"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/pkg/document"
)

// Task is struct representing a [document.CodeBlock] within the context of a project.
Expand Down
2 changes: 1 addition & 1 deletion internal/renderer/cmark/cmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/yuin/goldmark/ast"

"github.com/stateful/runme/v3/internal/document/constants"
"github.com/stateful/runme/v3/pkg/document/constants"
)

type NodeSourceProvider func(ast.Node) ([]byte, bool)
Expand Down
2 changes: 1 addition & 1 deletion internal/runner/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/go-git/go-billy/v5/osfs"
"github.com/muesli/cancelreader"
"github.com/pkg/errors"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/project"
"github.com/stateful/runme/v3/internal/runner"
runnerv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v1"
"github.com/stateful/runme/v3/pkg/document"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/runner/client/client_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (

"github.com/muesli/cancelreader"
"github.com/pkg/errors"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/project"
"github.com/stateful/runme/v3/internal/runner"
"github.com/stateful/runme/v3/internal/system"
runnerv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v1"
"github.com/stateful/runme/v3/pkg/document"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/runner/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

"github.com/pkg/errors"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/system"
"github.com/stateful/runme/v3/pkg/document"
)

type Shell struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (
"google.golang.org/grpc/reflection"

"github.com/stateful/runme/v3/internal/command"
"github.com/stateful/runme/v3/internal/document/editor/editorservice"
"github.com/stateful/runme/v3/internal/project/projectservice"
"github.com/stateful/runme/v3/internal/runnerv2service"
runmetls "github.com/stateful/runme/v3/internal/tls"
parserv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/parser/v1"
projectv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/project/v1"
runnerv2alpha1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/runner/v2alpha1"
"github.com/stateful/runme/v3/pkg/document/editor/editorservice"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/document/document.go → pkg/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/text"

"github.com/stateful/runme/v3/internal/document/constants"
"github.com/stateful/runme/v3/internal/renderer/cmark"
"github.com/stateful/runme/v3/pkg/document/constants"
)

var DefaultAttributeParser = newFailoverAttributeParser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/internal/renderer/cmark"
"github.com/stateful/runme/v3/pkg/document/identity"
)

var testIdentityResolver = identity.NewResolver(identity.DefaultLifecycleIdentity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/yuin/goldmark/ast"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/ulid"
"github.com/stateful/runme/v3/pkg/document"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/pkg/document"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/pkg/errors"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/constants"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/constants"
"github.com/stateful/runme/v3/pkg/document/identity"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/constants"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/internal/ulid"
"github.com/stateful/runme/v3/internal/version"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/constants"
"github.com/stateful/runme/v3/pkg/document/identity"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

"go.uber.org/zap"

"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/editor"
"github.com/stateful/runme/v3/internal/document/identity"
parserv1 "github.com/stateful/runme/v3/pkg/api/gen/proto/go/runme/parser/v1"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/editor"
"github.com/stateful/runme/v3/pkg/document/identity"
)

type parserServiceServer struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document/identity"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pkg/project/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-billy/v5/util"
"github.com/pkg/errors"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/identity"
)

func ReadMarkdownFile(filepath string, fs billy.Basic) ([]byte, error) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/project/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"time"

"github.com/pkg/errors"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/editor"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/internal/renderer/cmark"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/editor"
"github.com/stateful/runme/v3/pkg/document/identity"
)

type funcOutput func(string, []byte) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/pkg/errors"
"github.com/stateful/godotenv"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/pkg/document"
)

type CodeBlock struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/go-git/go-billy/v5/util"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/filesystem"
"github.com/stateful/runme/v3/internal/document"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document"
"github.com/stateful/runme/v3/pkg/document/identity"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 2 additions & 2 deletions web/main_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"syscall/js"

"github.com/stateful/runme/v3/internal/document/editor"
"github.com/stateful/runme/v3/internal/document/identity"
"github.com/stateful/runme/v3/pkg/document/editor"
"github.com/stateful/runme/v3/pkg/document/identity"
)

// These are variables so that they can be set during the build time.
Expand Down

0 comments on commit 6d103ae

Please sign in to comment.