dsccommunity / DscResource.DocGenerator

Module for generation of DSC resource documentation
MIT License
9 stars 10 forks source link

Correctly handle dashes in commands and general documentation in repository Wiki #156

Open johlju opened 1 day ago

johlju commented 1 day ago

Details of the scenario you tried and the problem that is occurring

GiutHub repository wiki uses the filename of the markdown file as the title in the wiki page. GitHub will automatically remove hyphens (-) from the file name, so a filename Visual-Studio-Code will end up with a page having the title Visual Studio Code. The problem is that the hyphen in a markdown file documentation a PowerShell command Get-Something is also removed so the title end up being Get Something.

When editing pages manually in the GitHub repository wiki and renaming a file to use hyphens, the hyphen - is converted to the unicode equivalent (U+2010).

[!NOTE] [From AI] The difference between the two symbols:

  • Hyphen (-): This is the standard hyphen that you see on most keyboards and is used in compound words (e.g., "well-known"), to join words, or to break a word at the end of a line. It is part of the standard ASCII character set and is typically found in everyday writing.
  • Hyphen (‐): This is the "Unicode hyphen" (U+2010). It looks visually similar to the standard hyphen but has a slightly different encoding in Unicode. It is used in typesetting and certain professional or digital contexts to ensure consistent line-breaking and word-joining behavior across different languages and scripts.

While they may appear nearly identical in most fonts, the main difference is that the standard hyphen is widely used in everyday typing (and is part of the ASCII set), whereas the Unicode hyphen is more specialized for precise typographic or encoding purposes.

Steps to reproduce the problem

Create and push a wiki page to the repository wiki that contain hyphens.

Expected behavior

Should remove hyphen for general markdown files to use as the title, but should not remove the hyphen from PowerShell commands.

Current behavior

Remove the hyphen from PowerShell commands.

Suggested solution to the issue

  1. When markdown files are created for commands the filenames should be created using the unicode hyphen (U+2010).
  2. The task `Generate_Wiki_Sidebar.build.ps1 should remove and ASCII hyphens from the sidebar entry similar to what GitHub does for page titles. Should not remove the unicode hyphens.
  3. Before markdown files are pushed to GitHub repository wiki by the task Publish_GitHub_Wiki_Content.build.ps1 the top header (#) should be removed from markdown files by a new task. This is to avoid each page having two titles.
  4. Publish_GitHub_Wiki_Content should be made a metatask that calls the above new task and the existing (need to be renamed) Publish_GitHub_Wiki_Content task so that this will work for all existing repos.

By have two separate tasks in a meta task a maintainer can choose to not run either task by configuring build.yaml accordingly.

The operating system the target node is running

n/a

Version and build of PowerShell the target node is running

n/a

Version of the module that was used

0.12.5

johlju commented 23 hours ago

I think we need to skip step 4, because we want the WikiContent to be correct (what we gonna publish) in the WikiContent artifact and that is create by Package_Wiki_Content. So we need to run a task prior to Package_Wiki_Content that renames and fixes the wiki content for GitHub publishing, e.g. a task Prepare_And_Clean_WikiContent_For_GitHub_Publish. Also maybe we shouldn't chnage the filenames when PowerShell Commands markdown are created, maybe we should have a task that renames files to use unicode hyphen before publish to GitHub.

This will result in that this task needs to be added to each repo that want to opt-in for this functionality. But might be harder to determine which files are commands and not.

Maybe we just need to assume GitHb is used for these tasks and just incoporate this into existing tasks?