Sidebar keeps closing nbdev

I’ve created a simple python package using nbdev. It worked really well. However, when I open the docs site that it generates and click on one of the sections, the sidebar keeps closing. Is there a way to keep it open always? I haven’t made any changes to the default template

Here’s what it looks like:

  1. Sidebar when I open the website:
    Screen Shot 2021-03-18 at 3.33.35 PM

  2. Side bar when I click on “utility functions”

and then I have to open the sidebar again.

Can you provide a link to a public repo that we can use to reproduce the issue. Also, can you open an issue on GitHub?

Thank you

I have the same issue on one of my repositories (https://kbressem.github.io/faimed3d/). It once disappeared for a while, but I was not able to find out what caused it.

Me too, I have this issue for my repository from a month.
Link: https://marcomatteo.github.io/steel_segmentation/

Sure, this is the link https://github.com/deep-word/dword

@hamelsmu any updates why this is happening?

I can provide one,

It’s a jekyll thing. Only if you make a nested list will you be able to kinda solve this and have it look better. But basically it’s because there is only one group it’ll just close it. Two groups should solve that, for ex look at my walk with fastai website or fastinference docs:

(However it may still be closed)

I’m looking into how we can change Jekyll to always highlight the open one, such as here:

3 Likes

@muellerzr I’m getting another error so I thought I’ll just post it here.

In my index.ipynb, I am showing doc for a function generate_video which is inside a class DeepWord. I’ve imported it and when I run index.ipynb it runs correctly as shown below.

However, when I run nbdev_build_docs I get the following error.

Any ideas what is happening?

Do you have the import in a #hide?

No I don’t. Funny, when I pushed it to Github there was no error. I have another question. I want to show a tutorial by running a notebook, but the notebook also uses api_key and secret_key which I cannot push to Github. Any workarounds for this?

@dipam Use secrets https://docs.github.com/en/actions/reference/encrypted-secrets

1 Like

I just wrote a small article on it in case it helps anyone : https://medium.datadriveninvestor.com/accessing-github-secrets-in-python-d3e758d8089b

1 Like

@muellerzr

I looked at your repo and saw that for two groups you would do
02_tutorial.bla.ipynb and 02_tutorial.bla2.ipynb.

I tried to do the same in this repo: https://github.com/deep-word/dword
but nbdev_build_docs complains that two notebooks have the same title “Title” and it doesn’t render properly in the docs. I have put default_exp also in them. Can you tell me what I am missing?

They don’t have actual titles. you need to include a title in a h1 tag (ie:

# Tutorial A
> my description

You’re error is likely saying it’s called Untitled something as a result

Notebook names and titles are different things :slight_smile: (the first only matters to the sidebar and URLs, the second is the actual name of the article/nb/section in the docs)

1 Like

Sorry to keep bothering you :man_facepalming: last question. @muellerzr
My notebooks are called
02_tutorials.educational.ipynb and 02_tutorials.sales.ipynb

The contents are as follows

[1]: # default_exp tutorials.educational

[2]: # tutorials.educational
      >  explanation for the page

and the same for the second notebook. However, this is creating 2 html pages on the main sidebar rather than creating a nested sidebar as you can see here

Do I have to change something else for a nested sidebar like the ones you have on fastinference?

Yes, I have a custom sidebar set. You should look at my sidebar.json file and set custom_sidebar=True in your settings.ini

1 Like

I had this same problem and finally figured it out by diving into the sidebar.html file in nbdev-jekyll-theme.

It turns out that it requires that the navigation links inside the sidebar menu not have the .html ending (it’s removed for pageurl on the second line of the sidebar.html file before comparison). Otherwise, it won’t mark the corresponding link in the sidebar as class=‘active’, and the sidebar will close.

So the solution is straightforward: remove the extension .html from all the links in your sidebar.json, and the sidebar menu should now function correctly.

I know this is a late response, but hopefully, it can still help people with the same problem.

@dipam7 @BresNet @marcomatteobuzz @muellerzr