docfx-companion-tools icon indicating copy to clipboard operation
docfx-companion-tools copied to clipboard

DocLinkChecker Doesn't understand File Inclusion links

Open AMSDavis opened this issue 2 years ago • 5 comments

When running DocLinkChecker it appears that the checker doesn't understand or find the links if I am using a file inclusion with a Code Snippet.

These links are rendered just find by docfx however DocLinkChecker believes they are an error.

As an example, if I have the following structure:

doc/
    index.md
    docfx.json
    scripts/
        foo.cs

and foo.cs has the following content like this:

// (other content above)

// <Bravo>
foreach(var thing in list)
{
     // Do Stuff
}
// </Bravo>

I can include the entire file with:

[!code-csharp[Code](~/Scripts/foo.cs)]

But this will be detected as an error by DocLinkChecker:

[!code-csharp[Code](~/Scripts/foo.cs?name=Bravo)]

AMSDavis avatar May 05 '23 23:05 AMSDavis

This should be fixed in a coming release. See https://github.com/Ellerbach/docfx-companion-tools/tree/doclinkchecker-upgrade You can build and test it to check if it now works better. Please report back if possible.

Ellerbach avatar May 16 '23 16:05 Ellerbach

@AMSDavis did you have a chance to test the new version published? It should fix your issue! Let us know so we can close this issue.

Ellerbach avatar Oct 12 '23 14:10 Ellerbach

Hello!

Just got the same issue in version 1.15.0.

I get warnings for line and region inclusions of csharp code snippets:

[!code-csharp[](../DemoProject/MyFile.cs#starting)]
private void MyMethod()
{
   #region starting
   // Some code
   #endregion
}

***WARNING Heading 'starting' not found in '../DemoProject/MyFile.cs'

Maybe this should be reported as separate issue, but I am also getting warnings for tabs:

## [Guide](#tab/text)

***WARNING Heading 'tab/text' not found in '.\Tabbed.md

Thank you!

Pixelrella avatar Nov 07 '23 15:11 Pixelrella

@Pixelrella sorry about that. I haven't had time to test that scenario. I have added this to the backlog.

mtirionMSFT avatar Nov 15 '23 10:11 mtirionMSFT

@Pixelrella I've been investigating this problem and it's harder then it looks. The functionality you are describing is not standard markdown (supported by markdig), but it's special for DocFx. There use to be a special markdig extension for these DocFx specials, but that's not supported anymore. I'm trying to see if there is a way to 'easily' add this support, otherwise I might end up writing our own markdig extension to solve this. But this will probably take some time.

So, just to let you know we're working on it :)

mtirionMSFT avatar Dec 13 '23 15:12 mtirionMSFT