0

I have been generating documentation with Docfx and everything works fine. Docfx generates .html files which is as expected.

However, since html files an be embedded in php files, I am looking for a way to generate the files as .php files rather than .html which I don't find any information.

I need this feature because I use a PHP templating engine in my application and I wanted to insert template variables in the markdown files for PHP to resolve dynamic values when being loaded in browser.

If this is possible, I would want a guide on how to do this. For instance, if I could locate and modify the file extension in the source code where the files are created.

Thanks in advance.

Daniel Oppong
  • 158
  • 1
  • 10

1 Answers1

0

There's no build-in feature for that. Since I ran into the same problem today, here's a small workaround to archive that (sample in powershell):

$destinationRoot = "path/to/doc"

[RegEx]$Search = '(\.html)"'
$Replace = '.php"'

ForEach ($File in (Get-ChildItem -Path $destinationRoot -Recurse -File)) {
    (Get-Content $File.FullName) -Replace $Search,$Replace | 
        Set-Content $File.FullName
}

After that you have to rename the files via script, too (it's not part of that script). You can archive that via modify the Set-Content $File.FullName command. You may wish to delete the old file, too.

Keep in mind it will replace links in the content, too, if they end with .html", but pages normally will not end with that extension, so it's an acceptable trade-off. If you really ran into that problem, just append a # or something else to the URL.

Arakis
  • 849
  • 5
  • 16