Skip to content

Commit

Permalink
Fix gendoc template
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Sep 20, 2022
1 parent d4547a3 commit 6132c65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
7 changes: 2 additions & 5 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<!---
!!! DO NOT MODIFY !!!
This file is auto-generated by the gendoc tool based on the source code of the app.
-->
---
# !!! DO NOT MODIFY !!!
# This file is auto-generated by the gendoc tool based on the source code of the app.
description: This section describes the configuration parameters and their types for INX-POI.
keywords:
- IOTA Node
Expand Down
26 changes: 18 additions & 8 deletions tools/gendoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"strings"

"github.com/iotaledger/hive.go/apputils/config"
"github.com/iotaledger/hive.go/core/app"
Expand All @@ -11,12 +12,7 @@ import (

func createMarkdownFile(app *app.App, markdownHeaderPath string, markdownFilePath string, ignoreFlags map[string]struct{}, replaceTopicNames map[string]string) {

markdownHeader := []byte(`<!---
!!! DO NOT MODIFY !!!
This file is auto-generated by the gendoc tool based on the source code of the app.
-->
`)
markdownHeader := ""

if markdownHeaderPath != "" {
var err error
Expand All @@ -25,12 +21,26 @@ This file is auto-generated by the gendoc tool based on the source code of the a
panic(err)
}

markdownHeader = append(markdownHeader, markdownHeaderFile...)
markdownHeader = string(markdownHeaderFile)
}

if strings.HasPrefix(markdownHeader, "---") {
// header contains frontmatter code block
markdownHeader = strings.Replace(markdownHeader, "---", `---
# !!! DO NOT MODIFY !!!
# This file is auto-generated by the gendoc tool based on the source code of the app.`, 1)
} else {
markdownHeader = `<!---
!!! DO NOT MODIFY !!!
This file is auto-generated by the gendoc tool based on the source code of the app.
-->
` + markdownHeader
}

println(fmt.Sprintf("Create markdown file for %s...", app.Info().Name))
md := config.GetConfigurationMarkdown(app.Config(), app.FlagSet(), ignoreFlags, replaceTopicNames)
if err := os.WriteFile(markdownFilePath, append(markdownHeader, []byte(md)...), os.ModePerm); err != nil {
if err := os.WriteFile(markdownFilePath, append([]byte(markdownHeader), []byte(md)...), os.ModePerm); err != nil {
panic(err)
}
println(fmt.Sprintf("Markdown file for %s stored: %s", app.Info().Name, markdownFilePath))
Expand Down

0 comments on commit 6132c65

Please sign in to comment.