docfx icon indicating copy to clipboard operation
docfx copied to clipboard

Level 2 navigation in navbar-header always expanded

Open subsembly opened this issue 7 years ago • 12 comments

DocFX Version Used: Version 2.40.12

Template used: (default or statictoc or contain custom template) Problem ist with default or statictoc templates

Steps to Reproduce:

Happens to me with any build from a C# class library. Regardless of targetframework or anything else I tried.

Expected Behavior:

The navbar-header only contains and shows the namespace entries.

Actual Behavior:

The navbar-header is populated with all classes and is always fully expanded, thus hiding everything else underneath. See screen shot attached. Tried with Chrome, Firefox and Edge browsers. Same behaviour.

navbar

By looking at the HTML in the browser, the hierarchy seems to be correct:

                      <li>
                          <span class="expand-stub"></span>
                          <a href="Subsembly.Sepa.html" title="Subsembly.Sepa">Subsembly.Sepa</a>
                          
                          <ul class="nav level2 navbar-nav">
                                <li>
                                    <a href="Subsembly.Sepa.SepaAccount.html" title="SepaAccount">SepaAccount</a>
                                </li>

subsembly avatar Mar 18 '19 09:03 subsembly

Do add dropdown: true in you toc.yml? Here is an example: https://github.com/dotnet/docfx/pull/3168

superyyrrzz avatar Mar 19 '19 01:03 superyyrrzz

Hi, thanks for your response. However, I am building the documentation from a .csproj file, hence the toc.yml is generated and any manual changes are overwritten as soon as I start docfx. Is it possible to add this option somewhere in the docfx.json file?

subsembly avatar Mar 19 '19 07:03 subsembly

Got your ideas. If you have tried docfx init, you can find the toc.yml from .csproj file is generated under api folder. Usually we do not put it on root folder to use it as navbar.

superyyrrzz avatar Mar 19 '19 14:03 superyyrrzz

Hi, thanks again for your quick response, but I am afraid that you still misunderstand my problem. I am using docfx for a long time now and it only started failing recently. As I said, the toc.yml is generated automatically when I build the documentation for my project. The metadata section in my docsfx.json file looks like this:

	"metadata": [
		{
			"disableGitFeatures": true,
			"src": [
				{
					"files": [ "Subsembly.Sepa3.Core.csproj" ]
				},
				{
					"src": "../../Subsembly.Swift/Subsembly.Swift",
					"files": [ "Subsembly.Swift.Core.csproj" ]
				}
			],
			"force": true,
			"dest": "obj/docfx"
		}
	],

Hence I always get a obj/docfx/toc.yml file generated, overwriting any manual changes that I do to it.

subsembly avatar Mar 19 '19 16:03 subsembly

Could you share your whole docfx.json? If it worked before, it sounds like a regression caused by #3168. But I think using toc.yml generated from metadata section as the navbar should never worked ... I'm curious what's the behavior before? Did it only show namespaces in TOC's first level?

superyyrrzz avatar Mar 20 '19 03:03 superyyrrzz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

stale[bot] avatar Jun 18 '19 03:06 stale[bot]

Closing this issue after a prolonged period of inactivity. If you still think this issue is relevant, please feel free to ping a maintainer or leave a comment.

stale[bot] avatar Jun 25 '19 04:06 stale[bot]

Hello! I've recently encountered this issue in a large project that I'm building documentation for. I'm actually extracting metadata from an entire solution file (with 26 projects), so I end up with a huge generated TOC. This is created in the metadata destination folder specified in my docfx.json, as expected.

If I add a separate toc.yml in the repo root (also where docfx.json is located), I get a warning about having two TOCs when I run docfx build. So, we can't override the autogenerated TOC this way.

Also, as the OP noted, any changes to that autogenerated TOC will be overwritten by subsequent docfx metadata runs. Ordinarily, I'd just add the dropdown: true parameter to the top-level toc.yml entries to make that top navigation bar a bit smaller, but given that overwriting behavior, this wouldn't work.

My proposed solution would be some sort of option (maybe in docfx.json?) to cause top-level entries of the autogenerated TOC to be dropdowns.

However, I'd also be curious to know why DocFX is using the generated TOC as the navbar in the first place. The above comments from @superyyrrzz imply that it shouldn't be doing so.

LRitzdorf avatar Jan 10 '22 21:01 LRitzdorf

The top-level toc.yml in DocFX's own documentation is used as the navigation bar and it then refers to another TOC in obj/temp/docfxapi/ for the API documentation.

How do you specify the toc.yml files in docfx.json when you get the warning about having two TOCs? Do you use a "dest" setting like here?

KalleOlaviNiemitalo avatar Jan 11 '22 11:01 KalleOlaviNiemitalo

@KalleOlaviNiemitalo Actually, I was able to solve this. My guess is that your docfx.json has something like:

"metadata": [
  {
    "src": [
      {
        "files": [
          "toc.yml",
          ...
        ],
        "exclude": ... ,
        "src": "some subfolder path"
      }
    ],
    "dest": "api"
  }
]

That inner "src" item was the problem for me. I tried to use it to specify where to retrieve a lower-level TOC from, but it turns out that's done automatically, based on entries in the top-level TOC. Removing or changing that src path should help with your issue, I think.

LRitzdorf avatar Jan 12 '22 21:01 LRitzdorf

Relatedly, my issue here was that the lower-level TOC (which usually forms the sidebar navigation panel) was being used as the top-level one (the navigation banner at the top of the site). Adding a simple top-level TOC (and changing the "src" path, as above) and referencing the secondary one from within it fixed my issue completely.

LRitzdorf avatar Jan 12 '22 21:01 LRitzdorf

@LRitzdorf, my docfx.json files actually do not have any "metadata" properties, as I am not using it for .NET API documentation. 😉

KalleOlaviNiemitalo avatar Jan 12 '22 22:01 KalleOlaviNiemitalo