Skip to content

Commit

Permalink
Merge pull request #210 from opencontrol/remove-docx
Browse files Browse the repository at this point in the history
remove docx templating logic
  • Loading branch information
jcscottiii committed Jul 28, 2016
2 parents 26ad09b + 0fdf751 commit 6986fa8
Show file tree
Hide file tree
Showing 27 changed files with 252 additions and 980 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.goxc.local.json
compliance-masonry
/compliance-masonry
*.swp
*.out
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ The content of the `markdowns/SUMMARY.md` and `markdowns/README.md` files and th

For more information on using the `SUMMARY.md` and `README.md` files visit the [Gitbook documentation.](http://toolchain.gitbook.com/structure.html) For an example `markdowns` directory visit the [cloud.gov `markdowns`](https://github.com/18F/cg-compliance/tree/master/markdowns).


### Viewing gitbook locally in browser

Requires [NodeJS](https://nodejs.org/). After running the steps above,
Expand Down Expand Up @@ -122,23 +121,7 @@ compliance-masonry get && compliance-masonry docs gitbook <certification>

## Create Docx template

1. Create a Word Document template that uses the following template tag format:

```
Documentation for Standard: NIST-800-53 and Control: CM-2 will be rendered below
{{ getControl "NIST-800-53@CM-2"}}
Documentation for Standard: NIST-800-53 and Control: AC-2 will be rendered below
{{ getControl "NIST-800-53@AC-2"}}
```

1. Run the docx command.

```bash
compliance-masonry docs docx -t path/to/template.docx
```

Running the `docx` command will by default create a file named `export.docx` in the local directory.
While there used to be Word document templating logic in Masonry, the team [found](https://github.com/opencontrol/compliance-masonry/issues/153) that it could be done more effectively with rendering code tailored to the specifics of the destination `*.docx`. See the [FedRAMP templater](https://github.com/opencontrol/fedramp-templater) for an example of using Compliance Masonry as a library to inject [OpenControl-formatted](https://github.com/opencontrol/schemas) documentation into a Word doc.

## Gap Analysis

Expand Down
16 changes: 0 additions & 16 deletions commands/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,10 @@ package docs
import (
"os"

"github.com/opencontrol/compliance-masonry/commands/docs/docx"
"github.com/opencontrol/compliance-masonry/commands/docs/gitbook"
"github.com/opencontrol/compliance-masonry/tools/certifications"
"errors"
)

func BuildTemplate(config docx.Config) error {
if config.TemplatePath == "" {
return errors.New("Error: No Template Supplied")
}
if _, err := os.Stat(config.TemplatePath); os.IsNotExist(err) {
return errors.New("Error: Template does not exist")
}
err := config.BuildDocx()
if err != nil {
return err
}
return nil
}

func MakeGitbook(config gitbook.Config) (string, []error) {
warning := ""
certificationPath, err := certifications.GetCertification(config.OpencontrolDir, config.Certification)
Expand Down
39 changes: 0 additions & 39 deletions commands/docs/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"

. "github.com/opencontrol/compliance-masonry/commands/docs"
"github.com/opencontrol/compliance-masonry/commands/docs/docx"
"github.com/opencontrol/compliance-masonry/commands/docs/gitbook"

. "github.com/onsi/ginkgo"
Expand All @@ -17,44 +16,6 @@ import (
)

var _ = Describe("Doc Tests", func() {
DescribeTable("BuildTemplateTest", func(config docx.Config, expectedMessages error) {
tempDir, _ := ioutil.TempDir("", "example")
defer os.RemoveAll(tempDir)
config.ExportPath = tempDir
actualMessages := BuildTemplate(config)
assert.Equal(GinkgoT(), expectedMessages, actualMessages)
},
Entry(
"Check the template method returns an error message when no template is defined",
docx.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures"),
TemplatePath: "",
ExportPath: "",
},
errors.New("Error: No Template Supplied"),
),

Entry(
"Check the template method returns an error message when no template does not exist",
docx.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures"),
TemplatePath: "fake",
ExportPath: "",
},
errors.New("Error: Template does not exist"),
),

Entry(
"Check that template is created when inputs are correct",
docx.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures"),
TemplatePath: filepath.Join("..", "..", "fixtures", "template_fixtures", "test.docx"),
ExportPath: "",
},
nil,
),
)

DescribeTable("BuildGitbookTest", func(config gitbook.Config, expectedWarning string, expectedMessages []error) {
tempDir, _ := ioutil.TempDir("", "example")
defer os.RemoveAll(tempDir)
Expand Down
194 changes: 0 additions & 194 deletions commands/docs/docx/docx.go

This file was deleted.

13 changes: 0 additions & 13 deletions commands/docs/docx/docx_suite_test.go

This file was deleted.

0 comments on commit 6986fa8

Please sign in to comment.