Code Monkey home page Code Monkey logo

Comments (15)

BernieWhite avatar BernieWhite commented on July 21, 2024

Looking at this one.

from platyps.

vors avatar vors commented on July 21, 2024

Cool, I also though about it recently.
Here is one option: we can

  1. switch to markdig (#112) because it has a stable API and is generally very good and extensible parser (this is in turns would be semi-dependent on #205 , but not really, just simpler if do in this order)
  2. customization would be super simple and generic:
  • callback at the beginning (== start), this is just to initialize things
  • callback with passing a path to the file after writing out the whole file on disk (== process)
  • callback at the end (== end)

We can even wrap it into a powershell function, because it maps very naturally.
Every callback could overwrite the generated file and leverage markdig for that.
One of motivation examples: resolve links, should be pretty straightforward to implement with this API. Same is probably true for the powershell monikers in the examples.

@BernieWhite do you see any flows?

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

@vors I think the key flow that will make a difference is before markdown render. Doing some prototyping on a few of the issues raised, they can generally be solved by a simple transformation on the MamlCommand before it is rendered.

Like you say it is probably best to link in markdig first. So I'll look at that approach.

Agreed that would have been easier to have the cross platform upgrade done first :) might take a few commits till we are happy with it.

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

We should also look at minimizing surface area. To make it easier to plug in a different markdown parser in the future and to make upgrades to the markdig package in the future.

from platyps.

vors avatar vors commented on July 21, 2024

Right, the callback on MamlCommand is also a good extensibility point.

I don't think that it would help with "cross-link relative links", but will definitely help with fixing monikers in examples.

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

@vors Ok for cross references. My thoughts are that we should leverage link references using convention to identify cross-references. This will make it easy to keep them up to date and they still work as links in GitHub and VSCode (and probably other markdown renderers).

i.e.

[New-MarkdownHelp][xref:New-MarkdownHelp]

[xref:New-MarkdownHelp]: New-MarkdownHelp.md

Not totally sold on the xref identifier only because it potentially clashes with docfx if we don't also use a uid in the header. Other alternatives could be ps or cmdlet.

Also I also had a thought that we could either relative link or link to the uri of the online version.

Thoughts?

from platyps.

vors avatar vors commented on July 21, 2024

oh interesting feature. Is it described in http://spec.commonmark.org/ ?

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

Link references are defined in the CommonMark spec. Use of : in the link label is permitted in CommonMark.

CommonMark, suggest ways to link markdown documents using full or relative links (when the location of the linked document is known).

CommonMark doesn't define a way to link entities like cmdlets, which is what the cross-references in docfx are trying to achieve. In the case of docfx the location of the linked document is not known at the time of authoring. docfx then does the linking at build time, but for all purposes the markdown documents have links that can't be resolved in the repo.

For the case of platyPS we want CommonMark renderers in editing tools and repos to be able to render the links. PowerShell already does that by topic name.

So my suggestion is just an extension of this, to provide a reference link that can be identified as linking to a cmdlet (as opposed to linking to other content) and updated in a Update-MarkdownHelp pass.

Another suggestion which is a simpler editing experience is to use a shortcut reference link, but it may be harder to identify links that can be automatically updated.

e.g.

[New-MarkdownHelp]

[New-MarkdownHelp]: New-MarkdownHelp.md

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

#138

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

Possibly setting an order of precedence is enough and i'm over thinking it.

i.e. If the contents of [] matches a cmdlet with the same name in the same module then link to it and keep the link updated.

from platyps.

vors avatar vors commented on July 21, 2024

updated in a Update-MarkdownHelp pass.

Not following, can you provide an example when it needs an update during this pass? Do you mean updating the LINKS section, if new xref is present?

I like the idea of leveraging the link labels, but want to make sure we know the scenarios we are trying to make better with added complexity.

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

@vors Yes. Add someone authoring the documentation start linking in parameter descriptions or notes references to cmdlets, we should link them in the related links section.

Also would we ever need to handle a situation where the relative path changed, like the file was renamed or moved to a subdirectory?

The more I think about it, I like the shortcut links better.

from platyps.

vors avatar vors commented on July 21, 2024

The renaming currently is handled pretty badly, even before the cross links we need to solve more basic things #106 .

I personally don't see much value in LINKS section in the context of markdown. Markdown has an overlapping feature reference links.

from platyps.

BernieWhite avatar BernieWhite commented on July 21, 2024

Reference link definitions themselves are not rendered by the CommonMark spec which isn't a problem for generating maml agreed. But online help needs them. So I can't see a way to not have them :) They would just use the reference link format.

# New-MarkdownHelp
...

## RELATED LINKS

[Character Encoding in the .NET Framework][dotnet-encoding]

[Using PowerShell to write a file in UTF-8 without the BOM][ps-utf]

[Update-MarkdownHelp]

[dotnet-encoding]: https://msdn.microsoft.com/en-us/library/ms404377.aspx
[ps-utf]: http://stackoverflow.com/questions/5596982/using-powershell-to-write-a-file-in-utf-8-without-the-bom
[Update-MarkdownHelp]: Update-MarkdownHelp.md

Since Get-Help -Online is supported in the PS engine, I think we need to account for displaying rendered markdown and it should closely match what is displayed on the command line in terms of content.

from platyps.

sdwheeler avatar sdwheeler commented on July 21, 2024

Our publishing system supports cross-ref links and markdown reference links. The PowerShell team is considering a switch from MAML to markdown for the help system, but that requires many breaking changes to the help system.

from platyps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.