Skip to content

Commit

Permalink
Don't generate separate completion/functions doc files
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jun 8, 2021
1 parent 092ef17 commit 4d72952
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: success()
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
fail_ci_if_error: false

release:
name: Release
Expand Down
18 changes: 10 additions & 8 deletions cmd/docgen/docs/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ func TestGenerateDocs(t *testing.T) {
require.NoError(t, err)

// check other outputs
completion := readJSONOutput(t, outputDir, "en-us", "completion.json").(map[string]interface{})
assert.Contains(t, completion, "types")
assert.Contains(t, completion, "root")
completion := readJSONOutput(t, outputDir, "en-us", "editor.json").(map[string]interface{})
assert.Contains(t, completion, "functions")
assert.Contains(t, completion, "context")

types := completion["types"].([]interface{})
context := completion["context"].(map[string]interface{})
functions := completion["functions"].([]interface{})

assert.Equal(t, 80, len(functions))

types := context["types"].([]interface{})
assert.Equal(t, 16, len(types))

root := completion["root"].([]interface{})
root := context["root"].([]interface{})
assert.Equal(t, 14, len(root))

functions := readJSONOutput(t, outputDir, "en-us", "functions.json").([]interface{})
assert.Equal(t, 80, len(functions))
}

func readJSONOutput(t *testing.T, file ...string) interface{} {
Expand Down
22 changes: 0 additions & 22 deletions cmd/docgen/docs/editor_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,6 @@ func (g *editorSupportGenerator) Generate(baseDir, outputDir string, items map[s
}
fmt.Printf(" > editor support file written to %s\n", outputPath)

// for backwards compatibility, write as two separate files as well
mapPath := path.Join(outputDir, "completion.json")
listingPath := path.Join(outputDir, "functions.json")

marshaled, err = jsonx.MarshalPretty(es.Context)
if err != nil {
return err
}
if err := ioutil.WriteFile(mapPath, marshaled, 0755); err != nil {
return err
}
fmt.Printf(" > %d completion map written to %s\n", len(items["context"]), mapPath)

marshaled, err = jsonx.MarshalPretty(es.Functions)
if err != nil {
return err
}
if err := ioutil.WriteFile(listingPath, marshaled, 0755); err != nil {
return err
}
fmt.Printf(" > %d functions written to %s\n", len(es.Functions), listingPath)

// also output list of context paths.. not used by the editor but useful for checking
if err := createContextPathListFile(outputDir, es.Context); err != nil {
return err
Expand Down

0 comments on commit 4d72952

Please sign in to comment.