Is there any command that I can use in cell to save the current notebook as HTML?
What I mean is command for this:

Maybe something like this?
# In the last cell
save_notebook_as_HTML('./file_name')
Not exactly, because the kernel, where your code runs, doesn't know about the notebook document. You can display some Javascript code that will trigger the download as HTML action, but that's kind of a hack.
If you want to make an HTML copy every time you save a notebook, you could do that with a save hook.
@takluyver I think another way maybe use the nbconvert?
But I didn't find the implementation of it in this repo, I can only trace it to MenuBar.prototype._nbconvert
Yes, you can use nbconvert to convert a notebook file to HTML.
Nbconvert lives in another repo: https://github.com/jupyter/nbconvert
Here's a link to the nbconvert and HTML section of the documentation for your convenience: https://nbconvert.readthedocs.org/en/latest/usage.html#default-output-format-html
@willwhitney @takluyver Thanks! Actually I have read these. The problem as I said, is that I want to know exactly how notebook use it, so I can re-use the code to convert the notebook in cells, for automation.
The doc at https://nbconvert.readthedocs.org/en/latest/nbconvert_library.html is not very easy to understand.
So far I have traced to this link (https://github.com/jupyter/notebook/blob/41d6da235cbf3bcf6d7f818e11a066e0fd12ff8b/notebook/static/notebook/js/menubar.js#L70),
and I can't find anything in notebook about HTMLExporter.
https://github.com/jupyter/notebook/search?utf8=%E2%9C%93&q=HTMLExporter
Could you give me more clues? Thanks!
@takluyver @willingc
It's half done. The code is this:
from nbconvert import HTMLExporter
import codecs
import nbformat
exporter = HTMLExporter()
output_notebook = nbformat.read('file_format.ipynb', as_version=4)
output, resources = exporter.from_notebook_node(output_notebook)
codecs.open('test.html', 'w', encoding='utf-8').write(output)
I leart it from https://github.com/paulgb/runipy
Most helpful comment
@takluyver @willingc
It's half done. The code is this:
I leart it from https://github.com/paulgb/runipy