Ability to expand namespaces by default in nested mode #8657
-
I am currently using release 2.65.3 with 'nested' layout to some success, thanks in part to @clement-or's helpful issue resolution (see issue #8540). However, when you go to the 'Api Documentation' home page, you see just the very top level namespace, which looks very sad all on its own. It would be much better if this top level namespace were expanded by default to show all the second level namespaces. (In an ideal world, it would be possible to specify which level to expand to.) Does anyone have any idea how to implement such a feature, or perhaps this is a spare-time job for the ever-helpful @NanoBob that fixed up nesting most recently? (If anyone can give me any pointers, I'm more than happy to knock together a PR.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I accomplished this by manually customizing the toc.yml file that gets generated in my api folder during the metadata command. I have separate json files for just metadata.json and build.json instead of docfx.json to run whichever commands I need as I work. So, after I run just the metadata command, then I manually overwrite the toc.yml file that was generated in the api folder. Then, I run the build command and my table of contents is all customized just the way I like it, without having to make separate namespaces or anything. The downsides are that I have to do this step in between metadata and build. There is probably some way to automate all of this, but I'm just doing it by hand for now. Also, it is error prone. Whatever I manually specify in the explicitly overwritten toc.yml file is what is displayed, regardless of code changes. If I create new classes I have to modify my overwrite toc file manually. So, because the toc.yml file is overwritten every time I run the metadata command, I keep my custom file in a separate location, outside of the api directory, saved as just a .txt file so it doesn't accidentally get picked up by glob patterns. One problem with that is that I have to be very careful that tabs don't accidentally get inserted instead of spaces and break the yml format. I use Notepad++ and have whitespace visible so I can easily see if this is the case. I have both files open in Notepad++ and after I run the metadata command I just go into the text editor and copy all from the custom txt file and paste all into the generated toc.yml file. Voila! My custom table of contents is now displayed. (After running docfx build.json --serve) So, to answer the original question. How do you expand the namespace by default? Use the expanded property in your custom yml file. Here is an example of mine. I have the first leaf node page specified for each level of the sub directory foldouts for my table of contents because that helps with the default template, so that if you click on any of the sub section headers it takes you to a relevant page. However, that's not necessary for the modern template the way I have it displayed now. I'm just particular like that, just FYI. items:
- name: Switchboard
uid: Switchboard
expanded: true
items:
- name: Core
uid: Switchboard.DynamicQueue`1
expanded: true
items:
- name: Collections
uid: Switchboard.DynamicQueue`1
items:
- name: DynamicQueue<T>
uid: Switchboard.DynamicQueue`1 Notice the expanded: true property. |
Beta Was this translation helpful? Give feedback.
I accomplished this by manually customizing the toc.yml file that gets generated in my api folder during the metadata command. I have separate json files for just metadata.json and build.json instead of docfx.json to run whichever commands I need as I work. So, after I run just the metadata command, then I manually overwrite the toc.yml file that was generated in the api folder. Then, I run the build command and my table of contents is all customized just the way I like it, without having to make separate namespaces or anything.
The downsides are that I have to do this step in between metadata and build. There is probably some way to automate all of this, but I'm just doing it by hand for…