Closed ConnorJL closed 4 years ago
The fix hadn't made its way to the generated html. The cell with HelloSayer
wasn't exported, so when building the docs, nbdev didn't know that function (it imports the corresponding module to build a page). Fixed by this commit.
Using show_docs in the index.ipynb even in the same cell as a function or class declaration does not work and throws an error while building the docs. It works when I use it inside the notebook cell itself though (core and index both!):
An error occurred while executing the following cell:
------------------
class HelloSayer:
"Say hello to `to` using `say_hello`"
def __init__(self, to): self.to = to
def say_hello(self):
"Say hello to somebody"
return f'Hello {self.to}!'
def say(self): print(say_hello(self.to))
show_doc(HelloSayer.say_hello)
------------------
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-7e1fcac685f1> in <module>
6 return f'Hello {self.to}!'
7 def say(self): print(say_hello(self.to))
----> 8 show_doc(HelloSayer.say_hello)
NameError: name 'show_doc' is not defined
NameError: name 'show_doc' is not defined
The funny thing is, it is creating a fine readme.md but not a index.html
The problem still exists.
I just encountered this. I also ran into a situation where nbdev_build_docs
was throwing NameError: name 'show_doc' is not defined
even after I had deleted the cell. I also edited the notebook and searched the directory and verified that the string 'show_doc' did not occur.
The solution was to run nbdev_build_lib
before nbdev_build_docs
. However, it did involve some back-and-forth of deleting .ipynb_checkpoints
, deleting the generated library code, reverting the deletion, rebuilding the library, and then building the docs.
I was following the tutorial and after implementing the HelloSayer class, the nb_build_docs command failed with:
This can be fixed by putting the show_doc(HelloSayer.say) in the same cell as the class definition, but this doesn't seem like intended behaviour so I thought I'd mention it.
The code leading to this error can be found here: https://github.com/ConnorJL/nbdev-test