Doraku / DefaultDocumentation

Create a simple markdown documentation from the Visual Studio xml one.
MIT No Attribution
157 stars 26 forks source link

Filtered out compiler generated types that are currently being included with "IncludeUndocumentedItems" #83

Closed hairlesshobo closed 2 years ago

hairlesshobo commented 2 years ago

I have identified two issues with the current implementation of the IncudeUndocumentedItems option.

1. The current output includes compiler generated "DisplayClass" types that should not be present.. see below:

#### [TerminalUI](index.md 'index')
## FoxHollow.TerminalUI Namespace

| Classes | |
| :--- | :--- |
| [Helpers](FoxHollow_TerminalUI_Helpers.md 'FoxHollow.TerminalUI.Helpers') | Static class containing miscellaneous helper methods  |
| [Helpers.<>c__DisplayClass0_0](FoxHollow_TerminalUI_Helpers___c__DisplayClass0_0.md 'FoxHollow.TerminalUI.Helpers.<>c__DisplayClass0_0') |  |
| [Helpers.<>c__DisplayClass0_0.<<SetupTaskWatchdog>b__0>d](FoxHollow_TerminalUI_Helpers___c__DisplayClass0_0___SetupTaskWatchdog_b__0_d.md 'FoxHollow.TerminalUI.Helpers.<>c__DisplayClass0_0.<<SetupTaskWatchdog>b__0>d') |  |
| [KeyInput](FoxHollow_TerminalUI_KeyInput.md 'FoxHollow.TerminalUI.KeyInput') | Class used for reading key input from the terminal  |
| [Terminal](FoxHollow_TerminalUI_Terminal.md 'FoxHollow.TerminalUI.Terminal') | Static helper class for simplifying a console-based, interactive user interface  |
| [Terminal.<>c__DisplayClass72_0](FoxHollow_TerminalUI_Terminal___c__DisplayClass72_0.md 'FoxHollow.TerminalUI.Terminal.<>c__DisplayClass72_0') |  |
| [Terminal.<>c__DisplayClass72_0.<<Run>b__0>d](FoxHollow_TerminalUI_Terminal___c__DisplayClass72_0___Run_b__0_d.md 'FoxHollow.TerminalUI.Terminal.<>c__DisplayClass72_0.<<Run>b__0>d') |  |
| [TerminalColor](FoxHollow_TerminalUI_TerminalColor.md 'FoxHollow.TerminalUI.TerminalColor') | Allow to specify the default colors for the terminal  |
| [TerminalPoint](FoxHollow_TerminalUI_TerminalPoint.md 'FoxHollow.TerminalUI.TerminalPoint') | Class used to make interacting with terminal positioning much easier  |
| [TerminalPointMove](FoxHollow_TerminalUI_TerminalPointMove.md 'FoxHollow.TerminalUI.TerminalPointMove') | TerminalPoint helper class that allows to wrap a TerminalPoint move action into a using() { } block so that, upon exiting the  block, the cursor is automatically returned to the previous location  |

I was able to filter these out by adding a check in DocItemReader using type.IsCompilerGeneratedOrIsInCompilerGeneratedClass(). I compared the output with and without this check in place, and the only difference that is now being excluded is the invalid classes.

See below for output AFTER this check was put in place:

#### [TerminalUI](index.md 'index')
## FoxHollow.TerminalUI Namespace

| Classes | |
| :--- | :--- |
| [Helpers](FoxHollow_TerminalUI_Helpers.md 'FoxHollow.TerminalUI.Helpers') | Static class containing miscellaneous helper methods<br/> |
| [KeyInput](FoxHollow_TerminalUI_KeyInput.md 'FoxHollow.TerminalUI.KeyInput') | Class used for reading key input from the terminal<br/> |
| [Terminal](FoxHollow_TerminalUI_Terminal.md 'FoxHollow.TerminalUI.Terminal') | Static helper class for simplifying a console-based, interactive user interface<br/> |
| [TerminalColor](FoxHollow_TerminalUI_TerminalColor.md 'FoxHollow.TerminalUI.TerminalColor') | Allow to specify the default colors for the terminal<br/> |
| [TerminalPoint](FoxHollow_TerminalUI_TerminalPoint.md 'FoxHollow.TerminalUI.TerminalPoint') | Class used to make interacting with terminal positioning much easier<br/> |
| [TerminalPointMove](FoxHollow_TerminalUI_TerminalPointMove.md 'FoxHollow.TerminalUI.TerminalPointMove') | TerminalPoint helper class that allows to wrap a TerminalPoint<br/>move action into a using() { } block so that, upon exiting the <br/>block, the cursor is automatically returned to the previous location<br/> |

2. The output generates a .md file and a _Module.md file, and an empty row in the index.md file. See below:

image

I have attached .md and _Module.md in case you would like to review what is being generated

.md Module.md

Additionally.., this is what the index.md file looks:

#### [TerminalUI](index.md 'index')

| Namespaces | |
| :--- | :--- |
| [](.md '') |  |
| [FoxHollow.TerminalUI](FoxHollow_TerminalUI.md 'FoxHollow.TerminalUI') |  |
| [FoxHollow.TerminalUI.Elements](FoxHollow_TerminalUI_Elements.md 'FoxHollow.TerminalUI.Elements') |  |
| [FoxHollow.TerminalUI.Types](FoxHollow_TerminalUI_Types.md 'FoxHollow.TerminalUI.Types') |  |

I was able to filter out this invalid namespace and type entry by looking for a type with no namespace defined in DocItemReader:

if (String.IsNullOrWhiteSpace(type.Namespace))
{
    _logger.Debug($"Skipping documentation for type \"{type.FullName}\": empty namespace");
    continue;
}

This pull request resolves both of these issues

hairlesshobo commented 2 years ago

Sure, I will give this a shot in the morning and let you know what I find.

hairlesshobo commented 2 years ago

OK, I made the requested change and confirmed that solution works as well.

Doraku commented 2 years ago

Thx again for those fixes :)