fdoc icon indicating copy to clipboard operation
fdoc copied to clipboard

Environment variable interpolation

Open knightq opened this issue 12 years ago • 5 comments

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.

knightq avatar Nov 04 '13 09:11 knightq

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?

zachmargolis avatar Nov 04 '13 17:11 zachmargolis

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?

knightq avatar Nov 05 '13 11:11 knightq

Ok so let's fix #52 then.

zachmargolis avatar Nov 05 '13 19:11 zachmargolis

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
...

knightq avatar Jan 17 '14 09:01 knightq

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

zachmargolis avatar Jan 17 '14 15:01 zachmargolis