docfx icon indicating copy to clipboard operation
docfx copied to clipboard

[Bug] Cannot exclude specific files

Open romanokeser opened this issue 2 years ago • 6 comments

Describe the bug I've built a .NET Core web API application. When executing docfx init, it successfully generates documentation hosted on localhost. However, I encounter an issue when trying to exclude files in the 'Services' folder. The output during the build process appears as follows:

No files are found with glob pattern images/**, excluding <none>, under directory "D:\CS\SpeechSeek"

Shouldn't it also indicate excluding "_site/**" and whatever I specify in docfx.json? Regardless of the patterns I specify in docfx.json, the 'excluding' information is always null. I need to exclude a couple of folders from the documentation generation.

This is my docfx.json:

{
  "metadata": [
    {
      "src": [
        {
          "src": "../Speechseek",
          "files": [
            "**/*.csproj"
          ]
        }
      ],
      "dest": "api"
    }
  ],
  "build": {
    "content": [
      {
        "files": [
          "**/*.{md,yml}"
        ],
        "exclude": [
          "_site/**",   <-- no excluded??
          "Services/**  <-- no excluded??
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "images/**"
        ]
      }
    ],
    "output": "_site",
    "template": [
      "default",
      "modern"
    ],
    "globalMetadata": {
      "_appName": "speechseek",
      "_appTitle": "speechseek",
      "_enableSearch": true,
      "pdf": false
    }
  }
}

Conclusion:

docfx builds the documentation but not excluding specific folders and .cs files

image I want to remove this files

romanokeser avatar Jan 30 '24 14:01 romanokeser

From your screenshot. It's intended to exclude SpeechSeekV2._0.Services namespace items from API` document page.

In this case. It need to configure Custom filter rules with following steps.

Steps

  1. Delete existing api folder contents.
  2. Add filterConfig.yal file with following contents
apiRules:
- exclude:
    uidRegex: ^SpeechSeekV2\._0\.Services
    type: Type
  1. Add "filter": "filterConfig.yml" config to metadata section

How to test

  1. Run docfx metadata command to generate API metadata
  2. Run docfx build --serve --open-browser command.
  3. Confirm launched browser page.

filzrev avatar Jan 30 '24 15:01 filzrev

uidRegex: ^SpeechSeekV2._0.Services
type: Type

This was the problem, what I have done first (forgot to put it in the post), was the type was namespace. Shouldn't that work as well? Like, every class within that namespace should be excluded? I'm a bit confused now, but I'm happy that it's finally working. Thanks for the reply :)

Edit: both type and namespace works, not sure why. Also the output is still: No files are found with glob pattern images/**, excluding <none>, under directory "D:\CS\SpeechSeek" Is this normal or it should output excluding SpeechSeekV2._0.Services instead of excluding<none> ?

romanokeser avatar Jan 30 '24 16:01 romanokeser

both type and namespace works, not sure why.

It can specify type: Namespace instead of type: Type. If you intended to exclude all types under specified namespace.

When it needs to include some part of the types that defined at excluded namespace. It need to use type: Type filter settings.

No files are found with glob pattern images/**, excluding , under directory "D:\CS\SpeechSeek" Is this normal or it should output excluding SpeechSeekV2._0.Services instead of excluding ?

This warning is because there are no files in D:\CS\SpeechSeek\images\**. And excluding <none> message is displayed because resource' section has no exclude' config.

 "resource": [
      {
        "files": [
          "images/**"
        ]
      }
    ],

filzrev avatar Jan 31 '24 00:01 filzrev

I encountered another bug (?). I managed to exclude SpeechSeekV2.0.Services, and then I started removing other things I don't need in my documentation. For example, Inherited Members make a lot of noise. I achieved this, but then Services would pop out again. I removed System.Object from the filterConfig.yml to exclude Services. However, I can't find a solution to remove both of them. And the most interesting thing now is that even though I removed Services for testing purposes, that namespace is still being excluded, even if it's not mentioned in filterConfig.yml??

Whenever I make changes, I build the documentation, and it throws an error if I have a typo in the filterConfig.yml, so I'm pretty sure that's not the problem.

image

image

I was following this documentation.

romanokeser avatar Jan 31 '24 09:01 romanokeser

It might needs to escape . with \. inside uidRegex. (I've fixed above example configs) What's the result of using the following configurations.

apiRules:
- exclude:
    uidRegex: ^SpeechSeekV2\._0.Services
    type: Type
- exclude:
    uidRegex: ^System\.Object

And when you add exclude rules. It's necessary to clean up api folder contents before running the `docfx metadata' command.

filzrev avatar Jan 31 '24 10:01 filzrev

Since I removed namespaces that have this, it's not mendatory. But I tested it to see if it works, and it doesn't. I'll move on because I don't need it anymore.

  • exclude: uidRegex: ^System.Object

And when you add exclude rules. It's necessary to clean up api folder contents before running the `docfx metadata' command.

Not sure what you mean by that? Couldn't find documentation referring to this...

Also, I can't remove constructors and Inherited Members: image image

I want to be left only with methods and their return types.

romanokeser avatar Jan 31 '24 11:01 romanokeser