A polyglot commenting language for generated markdown from code comments
| Language | File Types |
|---|---|
CSharp |
.cs |
Sql |
.sql |
JavaScript |
.js, .mjs, .ts, .tsx |
PowerShell |
.ps1, .psm1 |
function ConvertTo-RedactedPath
Swap the user's home directory for ~ so log lines never spill private paths.
Parameters
[string]: Path
Returns
[string]
$HOME replaced by ~.function Convert-SharpDownContent
Stream a source file's marker comments and declaration lines as Markdown.
Parameters
[string]: Source
[hashtable]: Config
$script:SharpDownConfig.[switch]: API
| Key | Description |
|---|---|
Marker |
The line prefix that signals a doc comment. |
Fence |
The code fence label applied to declarations. |
DeclPattern |
The regex that marks a line as a declaration. |
Read and trim each source line so the tests ignore indentation.
A marker line is doc text: emit it with the prefix removed.
Otherwise a declaration line becomes a fenced signature, unless -API.
Drop the trailing brace so the fence holds just the declaration.
Fence the cleaned signature with the language's label.
Returns
[string[]]
-API is set.function Resolve-SharpDownTarget
Compute the mirrored Markdown output path for a source file under -Recurse.
Parameters
[string]: Root
-Recurse.[string]: Source
[string]: ProjectName
Root. Stripped if it leads the relative path.[string]: OutRoot
-OutPath.Returns
[string]
.md to write.function Write-SharpDownFile
Convert a single source file and write the result. Skips with a warning when the source has no SharpDown content. Creates the output directory on demand.
Parameters
[string]: Source
[string]: Target
.md to write.[hashtable]: Config
$script:SharpDownConfig.[switch]: API
Convert-SharpDownContent. Suppresses auto-fenced declarations.Returns
[PSCustomObject]
[string]: Source
[string]: Target
[int]: Lines
function Invoke-SharpDownFile
Validate the File-mode contract and convert one source.
Parameters
[string]: Path
[string]: OutPath
.md path. Must not be an existing directory.[hashtable]: Config
$script:SharpDownConfig.[switch]: API
Write-SharpDownFile.Throws
Path is not a file.OutPath resolves to an existing directory.function Invoke-SharpDownTree
Validate the Directory-mode contract and walk a source tree.
Parameters
[string]: Path
[string]: OutPath
[hashtable]: Config
$script:SharpDownConfig.[string]: Language
[switch]: API
Write-SharpDownFile for each source file under the tree.Throws
Path is not a directory.OutPath resolves to an existing file.
| Key | Description |
| --- | --- |
| Extensions | The set of file extensions walked under -Recurse. |
| ExcludeRegex | The directory pattern skipped under -Recurse. |function ConvertTo-SharpDown
Public entry point. Convert a single source or a tree of sources to Markdown.
Two parameter sets:
-Path is a single source file, -OutPath is the .md target.-Recurse. -Path is a source directory, -OutPath is the output root. -Path accepts pipeline input from Get-Item and Get-ChildItem -Directory.Parameters
[string]: Language
CSharp, Sql, JavaScript, PowerShell. Defaults to CSharp.[string]: Path
[string]: OutPath
[switch]: Recurse
[switch]: API
Returns
[PSCustomObject[]]
[string]: Source
[string]: Target
[int]: Lines