docfx icon indicating copy to clipboard operation
docfx copied to clipboard

Exclude API class

Open dawsongh opened this issue 9 years ago • 7 comments

DocFX Version Used 2.22.2.0

Template used: default

Steps to Reproduce: Trying to exclude a specific class from being included, so I have added to docfx.json the filter option: ], "dest": "api", "filter": "filterConfig.yml" }

Inside the filerConfig.yml, I have tried two different ways.

  1. Using uidRegex on the namespace and class name
  2. Also by attribute as I added [Obsolete] before the class

Expected Behavior: I expect the class CRCdelme not to be included in the documentation, it seems that the filterConfig.yml is being opening but the excludes are not happening!

Actual Behavior: The class is included in the index and is documented in the _Site directory

filterConfig.yml

apiRules:

- exclude:
  uidRegex: '^FpAssistantCore\.BusinessObjects\.GeneralAviation\.CRCdelme$'
  type: Class

- exclude:
    hasAttribute:
      uid: System.ObsoleteAttribute
    type: Member

dawsongh avatar Aug 11 '17 15:08 dawsongh

@dawsongh 1, Please add 2 spaces before uidRegex and type in your first exclude, to make the yaml fit our internal data structure. 2. Update the type to Class to exclude the class with System.ObsoleteAttribute in your second exclude.

hellosnow avatar Aug 14 '17 03:08 hellosnow

@hellosnow

Thanks, changing type from member to Class solved got it working but I really don't want to mark my classes as [Obsolete] which I want excluded from the documentation.

So I have attached my filterConfig file (renamed with .txt extension). As you can see I have two spaces before the uidRegex.

Any idea why the Regex is not filtering out the class

Here is my code: namespace FpAssistantCore.BusinessObjects.GeneralAviation { using System;

public class CRCdelme {

filterConfig.txt

dawsongh avatar Aug 14 '17 12:08 dawsongh

@dawsongh uidRegex and type are the properties of exclude object, so please add two more spaces, e.g.:

apiRules:

- exclude:
    uidRegex: '^FpAssistantCore\.BusinessObjects\.GeneralAviation\.CRCdelme$'
    type: Class

vwxyzh avatar Aug 15 '17 02:08 vwxyzh

@hellosnow Many thanks, all now working.

dawsongh avatar Aug 15 '17 09:08 dawsongh

I am so happy I found this page! How am I supposed to ensure that 2 spaces are used by all editors? What if a tab is used? I know 0 spaces, 1 space, and 3 spaces fail. As a human, this is hard to see. All look the same structurally. If it is, so be it. How about a warning when I build documentation when my filterConfugration.yml is malformed due to whitespace? Silently failing/ignoring cost me hours and hours.

Quick, is this correct?

  • exclude: uidRegex: ^System.Object type: Type

I have subsequently fixed it, I copied it off the web from a team member. The original had one extra space. (I think it is correct, but I really do not know, I cannot see whitespace in this edtior).

I need an editor that marks whitespace to see whether or not it is correct (I've learned, I have one -- I simply didn't know it was needed, only web searches led me here). My usage experience gave me no clue. Silently ignoring my malformed excludes cost me hours and hours. I am likely not the first, nor likely the last.

I'm new to yml. Is it really so fragile? (no answer expected).

This was a horrible user experience. I got lucky, I found this article. I am persistent as hell. I had 3 spaces instead of 2, all of my exclusions were ignored. (And I copied an answer on github: my point, humans cannot handle this).

I ask you put this on your backlog. If you get a malformed exclude, fire an exception. In the alternative, if the malformation is whitespace, handle it and warn.

mprochaska avatar Jan 26 '19 12:01 mprochaska

@mprochaska I agree it is hard to make it work without some YAML syntax knowledge. I create a issue to track this #3986

superyyrrzz avatar Jan 29 '19 06:01 superyyrrzz

I just found this issue after struggling for days with getting the filterConfig.yml file working. I am not experienced in YAML at all. So @vwxyzh comment on adding two more spaces fixed it for me. Thank you so much! So for anyone having the same trouble in the future:

I was trying to filter out my namespace "RandomServices.API.Services" by the following lines:

apiRules:
- exclude:
  uidRegex: ^RandomServices\.API\.Services$
  type: Namespace

Which didn't work at all. Adding two spaces did the trick:

apiRules:
- exclude:
    uidRegex: ^RandomServices\.API\.Services$
    type: Namespace

This should really be emphasized in the documentation and validated in the filterConfig.yml as well.

RonniePoulsen avatar Jun 26 '20 09:06 RonniePoulsen