envdoc icon indicating copy to clipboard operation
envdoc copied to clipboard

Importing configs from other packages results in an empty value

Open miniscruff opened this issue 1 year ago • 2 comments

Consider a project layout such as

> config
    > env.example
    > CONFIGURATION.md
    > config.go
> models
    > config.go

If the config/config.go imports the models/config.go as part of its config, the resulting envdoc output will simply show as empty.

//go:generate go run github.com/g4s8/envdoc@latest -output CONFIGURATION.md -type Config -field-names
//go:generate go run github.com/g4s8/envdoc@latest -output .env.example -type Config -field-names -format dotenv

// Config manages all our app configurations.
type Config struct {
	Database models.PostgresConfig `envPrefix:"DB_"`
	// not included is my postgres config but imagine it has username, password, host, etc
}

Resulting markdown file:

# Environment Variables

## Config

Config manages all our app configurations.

 - `DATABASE` - 

I believe the issue is also relevant if you were importing from an entirely different project as well.

miniscruff avatar Apr 11 '24 07:04 miniscruff

@g4s8 definitely not trying to be pushy or rude but I do want to mention this again just in case it was missed. I would also be willing to take a look at doing it myself if it was a matter of time on your side. Thanks again.

miniscruff avatar May 05 '24 19:05 miniscruff

@miniscruff thanks for reminding my. This task could be a bit more complex as expected. First we need to restructure the ast parser to include package name context as a part of any type definition and then use it for type matching. Next, it's needed to support an additional flag pointing to project root. A new file-set should be created using the project root as a starting point. I'm going to do these tasks one by one. I'd really appreciate if you could help with any.

g4s8 avatar May 08 '24 22:05 g4s8