Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option hiddenCategories #1415

Closed
wants to merge 1 commit into from
Closed

Add option hiddenCategories #1415

wants to merge 1 commit into from

Conversation

tobiasschweizer
Copy link

@tobiasschweizer tobiasschweizer commented Dec 7, 2020

resolves #1407

This PR is not ready for review yet.

@tobiasschweizer
Copy link
Author

@Gerrit0 I could already add the declarations as described in #1407 (comment)

However, as for the category check I struggle a bit.

I would expect some logic as follows:

  • get the category of the class that is currently being processed
  • if the current class's category is contained in hiddenCategories, use project.removeReflection

@tobiasschweizer
Copy link
Author

If I understand correctly, there are three processing steps defined for the category plugin:

  1. onBegin
  2. onResolve
  3. onEndResolve

So would this have to go into onEndResolve (when everything is done) like:

    private onEndResolve(context: Context) {
        const project = context.project;
        this.categorize(project);
        if (this.hiddenCategories) {
             const reflections: Reflection[] = [];
             // check if `this.hiddenCategories` contains categories from `project`
             // push those reflections on `reflections `
             ...
             
             // remove reflections belonging to hidden categories from the documentation
             reflections.forEach(reflection => project.removeReflection(reflection))
        }
    }

How could I write a test for the new option?

@tobiasschweizer tobiasschweizer marked this pull request as draft December 7, 2020 19:08
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 9, 2020

You have the right idea - however, unfortunately due to the architecture of some of the other plugins (GroupPlugin is one of them), removing reflections after the onBegin method will break things... which I completely forgot about when I said this should be an easy issue. I haven't build a solution for this problem yet - to handle it properly the removeReflection method would need to emit an event so plugins that store reflection data can properly remove it... I think there is an issue open for this somewhere. This has been on the list for a while, I just haven't gotten around to it since I haven't needed it, and doing it properly requires reviewing all the existing plugins to ensure they handle the event properly... I'm looking into how difficult this is now, I might be able to finally do it this week.

Adding a test for this is pretty easy at least, I think this option can always be set, so we don't need a new spec file type:

  • In scripts/rebuild_specs.js and src/test/converter.test.ts add a hidden category in the options passed to app.bootstrap
  • In src/test/converter/comment add a new file exporting some values - some with the category tag, some without.
  • Run npm run rebuild_specs converter comment to generate a specs.json file with your changes

@tobiasschweizer
Copy link
Author

@Gerrit0 I understand :-) So ping me once you have implemented the necessary functionality for removeReflection and then I will try to finish this PR.

@tobiasschweizer
Copy link
Author

@Gerrit0 just a shot in the dark:
What about trying not to add the reflections that should be hidden/excluded? So we would not have to remove them.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 13, 2020

That could work as well - however that means that the categorization logic would have to happen earlier - instead of in the resolve event.... I'm not completely against that.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 14, 2020

I spent a few hours today trying to get the reflection removed event to work - this is trickier than I anticipated... TypeDoc is really bad about storing data in multiple places, and it is really easy to miss one of them... I think I mostly have it working except for inheritance. (@hidden comment on Parent in class Child extends Parent should totally hide parent... but it is only half being hidden)

@tobiasschweizer
Copy link
Author

@Gerrit0 sorry that I cannot help you there as I am not familiar with the architecture. Which branch are you working on?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 20, 2020

I never ended up pushing any of the changes for the removal event. There are more architectural difficulties than I realized.

  1. If removal can happen after the resolve step, every plugin which sets properties on reflections that reference another reflection needs to keep track of what properties are set so if that referenced reflection is removed, the reference can be removed.
  2. Allowing removal during the resolve step is especially problematic since the order that reflections are resolved in can affect the resulting output.

I think I'll need to dedicate a couple solid days to really going through and understanding all of the relations in order to properly handle this. I think the "right" solution is to do removal after resolution, but I also really dislike that solution since it adds a ridiculous amount of property tracking... which would be really easy to mess up. This probably won't happen this year, so unfortunately I think the best bet for this feature is to do filtering in onBeginResolve like the comment plugin does.

#1177 has some more notes on what "removal" ought to mean.

@tobiasschweizer
Copy link
Author

@lastthyme @Gerrit0 sorry, but this PR is not yet ready for review.

@tobiasschweizer
Copy link
Author

@Gerrit0 Hi, any chance to revive this PR? ;-)

@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 30, 2022

This probably won't happen this year, so unfortunately I think the best bet for this feature is to do filtering in onBeginResolve like the comment plugin does. - Me 2 years ago

This probably won't happen ever. It massively complicates a ton of logic. If updated to do as described, I'm still open to this.

@tobiasschweizer
Copy link
Author

This probably won't happen this year, so unfortunately I think the best bet for this feature is to do filtering in onBeginResolve like the comment plugin does. - Me 2 years ago

This probably won't happen ever. It massively complicates a ton of logic. If updated to do as described, I'm still open to this.

Shall I close this PR since I won't be able to work on this?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 31, 2022

It's still possible to do this - it just needs to be done at an earlier state. Removal needs to happen at EVENT_BEGIN_RESOLVE instead of later

@Gerrit0 Gerrit0 closed this in bcf3e04 Sep 4, 2023
@tobiasschweizer
Copy link
Author

cool :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add New Option hiddenCategories
2 participants