[Repo Assist] Add dotnet fsdocs convert command for single-file conversion#1019
[Repo Assist] Add dotnet fsdocs convert command for single-file conversion#1019github-actions[bot] wants to merge 17 commits intomainfrom
dotnet fsdocs convert command for single-file conversion#1019Conversation
Implement a new 'convert' verb for the fsdocs CLI tool that converts a single .md, .fsx, or .ipynb file to HTML (or other formats) without building a full documentation site. - Add Literate.ConvertPynbFile public API (parallel to ConvertMarkdownFile and ConvertScriptFile) - Add ConvertCommand CLI verb with --input, --output, --template, --outputformat, --eval, --linenumbers, --parameters options - Register ConvertCommand in Program.fs entry point - Update RELEASE_NOTES.md Usage: dotnet fsdocs convert --input notebook.ipynb dotnet fsdocs convert --input file.fsx --output file.html dotnet fsdocs convert --input doc.md --outputformat markdown Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| abstract port_option: int | ||
| default x.port_option = 0 | ||
|
|
||
| [<Verb("convert", |
There was a problem hiding this comment.
/repo-assist it might be time to split these commands up to multiple files.
There was a problem hiding this comment.
Yup these "/repo-assist" in PR comments still not working
|
/repo-assist Add comprehensive unit tests for all new code and integration tests for all new features |
- Unit tests for Literate.ConvertPynbFile: HTML without/with template, Markdown output, FSX output - Integration tests for ConvertCommand.Execute: .md, .fsx, .ipynb conversion, markdown output format, error codes for missing file and unsupported extension Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
|
/repo-assist I tried this out and it worked OK. However note how pandoc has this: where fsdocs convert has the longer I'd like to see more like where
Also I'd like to see the "Integration tests for ConvertCommand" moved to a set of tests for |
- Make input file positional (Value(0)) instead of --input flag - Add -o shorthand for --output - Infer output format from output file extension when --outputformat not specified - Move ConvertCommand integration tests to new fsdocs-tool.Tests project - Add new test for format inference from extension - Add fsdocs-tool.Tests to solution Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
|
Hi @nhirschey, would you mind giving this a spin? |
This comment was marked as resolved.
This comment was marked as resolved.
…d releases A blank line within a subsection (e.g. ### Added) causes Ionide.KeepAChangelog 0.1.8 to stop parsing the file, resulting in an empty Releases list. The previous List.head call gave a cryptic 'The input list was empty' error. This replaces it with a pattern match and an actionable error message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
|
sorry @nojaf I did not notice this until just now. /repo-assist when no html template is given you should not include the tooltip type info at the bottom of the html output because it does not get rendered usefully. It just ends up as junk at the bottom of the file. For example with this input .fsx file and no template given type RecordExample =
{ BeginningPrice : float
EndingPrice : float
Dividend : float }
let x = { BeginningPrice = 100.0; EndingPrice = 110.0; Dividend = 0.0}Remove all divs with class "fsdocs-tip" from the resulting output. Instead of this below that you are outputting now <html>
<body>
<!--StartFragment-->
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">type</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="rt">RecordExample</span> <span class="o">=</span>
--
<span class="pn">{</span> <span class="prop">BeginningPrice</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 2)" onmouseover="showTip(event, 'fs2', 2)" class="vt">float</span>
<span class="prop">EndingPrice</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 3)" onmouseover="showTip(event, 'fs2', 3)" class="vt">float</span>
<span class="prop">Dividend</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 4)" onmouseover="showTip(event, 'fs2', 4)" class="vt">float</span> <span class="pn">}</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs3', 5)" onmouseover="showTip(event, 'fs3', 5)" class="id">x</span> <span class="o">=</span> <span class="pn">{</span> <span class="prop">BeginningPrice</span> <span class="o">=</span> <span class="n">100.0</span><span class="pn">;</span> <span class="prop">EndingPrice</span> <span class="o">=</span> <span class="n">110.0</span><span class="pn">;</span> <span class="prop">Dividend</span> <span class="o">=</span> <span class="n">0.0</span><span class="pn">}</span>
</code></pre>
<div class="fsdocs-tip" id="fs1">type RecordExample =
{
BeginningPrice: float
EndingPrice: float
Dividend: float
}</div>
<div class="fsdocs-tip" id="fs2">Multiple items<br />val float: value: 'T -> float (requires member op_Explicit)<br /><br />--------------------<br />type float = System.Double<br /><br />--------------------<br />type float<'Measure> =
float</div>
<div class="fsdocs-tip" id="fs3">val x: RecordExample</div>
<!--EndFragment-->
</body>
</html>Give this, the same with the tooltip divs removed <html>
<body>
<!--StartFragment-->
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">type</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="rt">RecordExample</span> <span class="o">=</span>
--
<span class="pn">{</span> <span class="prop">BeginningPrice</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 2)" onmouseover="showTip(event, 'fs2', 2)" class="vt">float</span>
<span class="prop">EndingPrice</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 3)" onmouseover="showTip(event, 'fs2', 3)" class="vt">float</span>
<span class="prop">Dividend</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs2', 4)" onmouseover="showTip(event, 'fs2', 4)" class="vt">float</span> <span class="pn">}</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs3', 5)" onmouseover="showTip(event, 'fs3', 5)" class="id">x</span> <span class="o">=</span> <span class="pn">{</span> <span class="prop">BeginningPrice</span> <span class="o">=</span> <span class="n">100.0</span><span class="pn">;</span> <span class="prop">EndingPrice</span> <span class="o">=</span> <span class="n">110.0</span><span class="pn">;</span> <span class="prop">Dividend</span> <span class="o">=</span> <span class="n">0.0</span><span class="pn">}</span>
</code></pre>
<!--EndFragment-->
</body>
</html> |
|
/repo-assist do as instructed on #1019 (comment) |
When no template is provided (e.g. fsdocs convert without --template), tooltip divs with class fsdocs-tip are now omitted from the output. Tooltips require JavaScript/CSS injected by a template to function, so including them in raw output was not useful and could clutter the result. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 This is an automated response from Repo Assist. Done! I've pushed a commit that removes Change: In Test added: All 8 tests pass.
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #811
Summary
This adds a new
convertverb to thefsdocsCLI tool, enabling conversion of a single.md,.fsx, or.ipynbfile to HTML (or another output format) without needing to build a full documentation site.Usage examples:
Changes
src/FSharp.Formatting.Literate/Literate.fs: AddedLiterate.ConvertPynbFilepublic API method (parallel to the existingConvertMarkdownFileandConvertScriptFile)src/fsdocs-tool/BuildCommand.fs: AddedConvertCommandclass with[(Verb("convert"))]src/fsdocs-tool/Program.fs: RegisteredConvertCommandin the entry pointRELEASE_NOTES.md: Added changelog entryOptions
--input.md,.fsx,.ipynb)--output(basename).(ext)--template--outputformathtmlhtml,ipynb,latex,fsx,markdown--eval--linenumbers--parametersWhen no template is provided, raw HTML content is written (just the body, no surrounding page chrome) — the same behaviour as calling
Literate.ConvertMarkdownFilewith no template.Root Cause
The
Literatelibrary already exposedConvertMarkdownFileandConvertScriptFilefor programmatic use, and theDocContentclass inside the build command already performs per-file conversion. This PR wires those existing capabilities up to a new CLI verb and adds the missingConvertPynbFilemethod.Test Status
System.Drawing.Commonvulnerability)