square / fdoc

Documentation format and verification
Other
380 stars 59 forks source link

Environment variable interpolation #51

Open knightq opened 10 years ago

knightq commented 10 years ago

To get the right documentation published on different deploy contexts (i.e. both on staging environment and production environment) it would be very useful to be able to use environment variables inside fdoc.

In particular, it would be nice to be able to write something like this:

# my_service.fdoc.service
...
basePath: $env['CURRENT_ENV_BASE_PATH']/v1
...

So that when the documentation gets generated (deploy time), the right URL gets generated too into documentation.

zachmargolis commented 10 years ago

One thing I've done for our internal fdoc documentation generation here is ERB the .fdoc.service file. I suspect you already have a script running to kick off the HTML generation, what about adding a pre-process step there?

knightq commented 10 years ago

You are right: I already have a rake task that is invoked at deploy time to generate the HTML generation and it does something like this:

...
`fdoc convert #{file} --output=#{dest} --url-base-path=#{ENV['API_WEB_SERVER']}/docs --templates=#{template}`
...

the problem here is that - due to issue #52 - the --url-base-path option seems to get ignored by fdoc convert command.

Of course I could do something like pre-processing all .fdoc files in order to change each basePath value, but it would be quite tricky, doesn't it?

zachmargolis commented 10 years ago

Ok so let's fix #52 then.

knightq commented 10 years ago

The ERB preprocessing of .fdoc.service files you've already done for your internal doc might be become a feature, isn't it?

It will be sufficient to close this issue if I were able to write something like this:

# my_service.fdoc.service
...
basePath: <%= env['CURRENT_ENV_BASE_PATH'] %>/v1
...
zachmargolis commented 10 years ago

Ah great, glad it's that simple! Want to make a PR?