Doraku / DefaultDocumentation

Create a simple markdown documentation from the Visual Studio xml one.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to link a whole namespace, instead of every item within it?

tommygebhardtGarmin opened this issue · comments

I'm looking to link to the NetTopologySuite documentation (https://nettopologysuite.github.io/NetTopologySuite/api/NetTopologySuite.html) and would love to not create an entry in a links file for every single type/method/field that I am referencing in my comments. Is there a way to make the extern links file create those links with some amount of pattern matching?

That's actually what is stopping me from release the new version of this tool. Currently if a type has no known documentation it will try to create a dotnet api link. It would be great to allow people to add more documentation link generation logic for such case when a documentation exist but it was not generated by DefaultDocumentaion (so no links file) but it is nonetheless possible to infer the actual link for the id.
If something like this would be ok with you (create an external plugin for DefaultDocumentation to help you infer the documentation for NetTopologySuite from ids), I will see how to open this for user.

You're right, I hadn't fully thought of how challenging a problem it is to create the URLs. I was thinking something like a "generalized" links file, that would specify how to generate the URLs with keywords or patterns, like your example here:

http://extern/assembly/documentation/base/url/
T:ExternAssembly.ExternType|extern_type.html|ExternType
M:ExternAssembly.ExternType.ExternMethod|extern_type_extern_method.html|ExternType
http://extern/other/assembly/documentation/base/url/
T:OtherExternAssembly.ExternType|extern_type.html|ExternType

What if instead of extern_type.html in the third field, we had something like ExternAssembly.ExternType.html, that would fill in those details for everything matching "T". This might not be fully general, but it could be a way to do it with using existing infrastructure a bit?
For example for NTS, the file could look like:

https://nettopologysuite.github.io/NetTopologySuite/api/
N:NetTopologySuite.ExternNamespace|NetTopologySuite.ExternNamespace.html|ExternNamespace
T:NetTopologySuite.ExternNamespace.ExternType|NetTopologySuite.ExternNamespace.ExternType.html|ExternType
...

So, for instance, the namespace "Algorithm" would map to https://nettopologysuite.github.io/NetTopologySuite/api/NetTopologySuite.Algorithm.html, and display as "Algorithm", where
the type "AngleUtility" would map to https://nettopologysuite.github.io/NetTopologySuite/api/NetTopologySuite.Algorithm.AngleUtility.html and display as "AngleUtility"

Having this kind of logic in the links file would be very complicated. What if the reserved key is an actual namespace/type ^^"
Instead in the next version you will be able to create a plugin with your own implementation of IUrlFactory to use in the documentation generation. A rough example would be something like that:

    public sealed class NetTopologySuiteFactory : IUrlFactory
    {
        public string Name => "NetTopologySuite";

        public string GetUrl(IGeneralContext context, string id)
        {
            itemId = id.Substring(2);
            if (!itemId.StartWith("NetTopologySuite")
            {
                // not NetTopologySuite so we let the next IUrlFactory handle it
                return null;
            }

            // do some magic mapping there
            return $"https://nettopologysuite.github.io/NetTopologySuite/api/{itemId}";
        }
    }

Would that works for you?

Probably! I'm willing to give it a shot, for sure

New version 0.8.0 is now live. Feel free to reopen this issue or create a new one if you need help!