mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-08-06 16:41:19 +08:00
feat: generate default configs for docs without compiled binaries
This commit is contained in:
2
.github/workflows/check.yml
vendored
2
.github/workflows/check.yml
vendored
@ -35,8 +35,6 @@ jobs:
|
||||
- run: git diff --exit-code
|
||||
- run: make docsgen-cli
|
||||
- run: git diff --exit-code
|
||||
- run: make docsgen-config
|
||||
- run: git diff --exit-code
|
||||
check-lint:
|
||||
name: Check (lint-all)
|
||||
runs-on: ubuntu-latest
|
||||
|
8
Makefile
8
Makefile
@ -339,7 +339,7 @@ fiximports:
|
||||
|
||||
gen: actors-code-gen type-gen cfgdoc-gen docsgen api-gen
|
||||
$(GOCC) run ./scripts/fiximports
|
||||
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO RUN 'make docsgen-cli' and/or 'make docsgen-config'"
|
||||
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO RUN 'make docsgen-cli'"
|
||||
.PHONY: gen
|
||||
|
||||
jen: gen
|
||||
@ -352,12 +352,6 @@ docsgen-cli:
|
||||
$(GOCC) run ./scripts/docsgen-cli
|
||||
.PHONY: docsgen-cli
|
||||
|
||||
# Compiled lotus and lotus-miner are required to generate the default config files
|
||||
docsgen-config: lotus lotus-miner
|
||||
./lotus config default > documentation/en/default-lotus-config.toml
|
||||
./lotus-miner config default > documentation/en/default-lotus-miner-config.toml
|
||||
.PHONY: docsgen-config
|
||||
|
||||
print-%:
|
||||
@echo $*=$($*)
|
||||
|
||||
|
@ -1397,10 +1397,10 @@ OPTIONS:
|
||||
|
||||
```
|
||||
NAME:
|
||||
lotus auth create-token - Create token
|
||||
lotus-miner auth create-token - Create token
|
||||
|
||||
USAGE:
|
||||
lotus auth create-token [command options] [arguments...]
|
||||
lotus-miner auth create-token [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--perm value permission to assign to the token, one of: read, write, sign, admin
|
||||
@ -1411,10 +1411,10 @@ OPTIONS:
|
||||
|
||||
```
|
||||
NAME:
|
||||
lotus auth api-info - Get token with API info required to connect to this node
|
||||
lotus-miner auth api-info - Get token with API info required to connect to this node
|
||||
|
||||
USAGE:
|
||||
lotus auth api-info [command options] [arguments...]
|
||||
lotus-miner auth api-info [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--perm value permission to assign to the token, one of: read, write, sign, admin
|
||||
@ -1444,10 +1444,10 @@ OPTIONS:
|
||||
|
||||
```
|
||||
NAME:
|
||||
lotus log list - List log systems
|
||||
lotus-miner log list - List log systems
|
||||
|
||||
USAGE:
|
||||
lotus log list [command options] [arguments...]
|
||||
lotus-miner log list [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help
|
||||
@ -1457,10 +1457,10 @@ OPTIONS:
|
||||
|
||||
```
|
||||
NAME:
|
||||
lotus log set-level - Set log level
|
||||
lotus-miner log set-level - Set log level
|
||||
|
||||
USAGE:
|
||||
lotus log set-level [command options] [level]
|
||||
lotus-miner log set-level [command options] [level]
|
||||
|
||||
DESCRIPTION:
|
||||
Set the log level for logging systems:
|
||||
@ -1491,10 +1491,10 @@ OPTIONS:
|
||||
|
||||
```
|
||||
NAME:
|
||||
lotus log alerts - Get alert states
|
||||
lotus-miner log alerts - Get alert states
|
||||
|
||||
USAGE:
|
||||
lotus log alerts [command options] [arguments...]
|
||||
lotus-miner log alerts [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--all get all (active and inactive) alerts (default: false)
|
||||
|
@ -377,4 +377,3 @@
|
||||
# env var: LOTUS_FAULTREPORTER_CONSENSUSFAULTREPORTERADDRESS
|
||||
#ConsensusFaultReporterAddress = ""
|
||||
|
||||
|
||||
|
@ -650,4 +650,3 @@
|
||||
# env var: LOTUS_HARMONYDB_PORT
|
||||
#Port = "5433"
|
||||
|
||||
|
||||
|
@ -248,7 +248,7 @@ Note: one only needs to update `filecion-ffi`'s dependency on `go-state-types` w
|
||||
|
||||
11. Run `make gen`.
|
||||
|
||||
12. Run `make docsgen-cli docsgen-config`.
|
||||
12. Run `make docsgen-cli`.
|
||||
|
||||
And you're done! These are all the steps necessary to create a network upgrade skeleton that you will be able to run in a local devnet, and creates a basis where you can start testing new FIPs. When running a local developer network from this Lotus branch, bringing in all it dependencies, you should be able to:
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
<!--{{ if contains "Miner" .Type}}-->
|
||||
- Ensure to update `MinerBuildVersion`
|
||||
<!--{{ end}}-->
|
||||
- [ ] Run `make gen && make docsgen-cli docsgen-config` before committing changes.
|
||||
- [ ] Run `make gen && make docsgen-cli` before committing changes.
|
||||
- [ ] Update the CHANGELOG
|
||||
- [ ] Change the `UNRELEASED` section header to `UNRELEASED v{{.Tag}}`
|
||||
- [ ] Set the `UNRELEASED v{{.Tag}}` section's content to be "_See https://github.com/filecoin-project/lotus/blob/release/v{{.Tag}}/CHANGELOG.md_"
|
||||
@ -118,7 +118,7 @@
|
||||
<!-- {{if contains "Miner" $.Type}}-->
|
||||
- Ensure to update `MinerBuildVersion`
|
||||
<!-- {{end}}-->
|
||||
- [ ] Run `make gen && make docsgen-cli docsgen-config` to generate documentation
|
||||
- [ ] Run `make gen && make docsgen-cli` to generate documentation
|
||||
- [ ] Create a draft PR with title `build: release Lotus {{$.Type}} v{{$.Tag}}{{$tagSuffix}}`
|
||||
- Link to PR:
|
||||
- Opening a PR will trigger a CI run that will build assets, create a draft GitHub release, and attach the assets.
|
||||
|
@ -3,12 +3,14 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/filecoin-project/lotus/cli/lotus"
|
||||
"github.com/filecoin-project/lotus/cli/miner"
|
||||
"github.com/filecoin-project/lotus/cli/worker"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -45,6 +47,22 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cliApps := loadCLIApps()
|
||||
|
||||
fmt.Println("Generating CLI documentation...")
|
||||
failed := generateCLIDocumentation(cliApps)
|
||||
|
||||
fmt.Println("Generating default config files...")
|
||||
failed = generateDefaultConfigs() || failed
|
||||
|
||||
if failed {
|
||||
fmt.Println("Documentation generation failed.")
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Documentation generation complete.")
|
||||
}
|
||||
|
||||
func loadCLIApps() map[string]*cli.App {
|
||||
// Some help output is generated based on whether the output is a terminal or not. To make stable
|
||||
// output text, we set Stdout to not be a terminal while we load the CLI apps and reset it
|
||||
// before generating the documentation.
|
||||
@ -58,23 +76,64 @@ func main() {
|
||||
"lotus-miner": miner.App(),
|
||||
}
|
||||
|
||||
w.Close()
|
||||
_ = w.Close()
|
||||
os.Stdout = stdout
|
||||
|
||||
fmt.Println("Generating CLI documentation...")
|
||||
return cliApps
|
||||
}
|
||||
|
||||
func generateCLIDocumentation(cliApps map[string]*cli.App) bool {
|
||||
var failed bool
|
||||
for name, app := range cliApps {
|
||||
for _, cmd := range app.Commands {
|
||||
cmd.HelpName = fmt.Sprintf("%s %s", app.HelpName, cmd.Name)
|
||||
}
|
||||
resetCommandHelpName(app)
|
||||
|
||||
generator := NewDocGenerator(outputDir, app)
|
||||
if err := generator.Generate(name); err != nil {
|
||||
fmt.Printf(" ❌ %s: %v\n", name, err)
|
||||
failed = true
|
||||
continue
|
||||
}
|
||||
fmt.Printf(" ✅ %s\n", name)
|
||||
}
|
||||
|
||||
fmt.Println("Documentation generation complete.")
|
||||
return failed
|
||||
}
|
||||
|
||||
// resetCommandHelpName resets the HelpName of all commands to include the parent command names.
|
||||
// This is needed for the case where Commands are shared between apps.
|
||||
func resetCommandHelpName(app *cli.App) {
|
||||
var fix func(cmds []*cli.Command, helpName string)
|
||||
fix = func(cmds []*cli.Command, helpName string) {
|
||||
for _, cmd := range cmds {
|
||||
cmd.HelpName = fmt.Sprintf("%s %s", helpName, cmd.Name)
|
||||
fix(cmd.Subcommands, cmd.HelpName)
|
||||
}
|
||||
}
|
||||
fix(app.Commands, app.HelpName)
|
||||
}
|
||||
|
||||
func generateDefaultConfigs() bool {
|
||||
var failed bool
|
||||
if err := generateDefaultConfig(config.DefaultFullNode(), "default-lotus-config.toml"); err != nil {
|
||||
fmt.Printf(" ❌ %s: %v\n", "lotus", err)
|
||||
failed = true
|
||||
} else {
|
||||
fmt.Printf(" ✅ %s\n", "lotus")
|
||||
}
|
||||
|
||||
if err := generateDefaultConfig(config.DefaultStorageMiner(), "default-lotus-miner-config.toml"); err != nil {
|
||||
fmt.Printf(" ❌ %s: %v\n", "lotus-miner", err)
|
||||
failed = true
|
||||
} else {
|
||||
fmt.Printf(" ✅ %s\n", "lotus-miner")
|
||||
}
|
||||
return failed
|
||||
}
|
||||
|
||||
func generateDefaultConfig(c interface{}, file string) error {
|
||||
cb, err := config.ConfigUpdate(c, nil, config.Commented(true), config.DefaultKeepUncommented())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
output := filepath.Join(outputDir, file)
|
||||
return os.WriteFile(output, cb, 0644)
|
||||
}
|
||||
|
Reference in New Issue
Block a user