module helpgen.post_process

Short summary

module pyquickhelper.helpgen.post_process

Contains the main function to generate the documentation for a module designed the same way as this one, generate_help_sphinx().

source on GitHub

Functions

function

truncated documentation

_notebook_replacements

Makes some replacements in a notebook.

post_process_html_output

Processes a HTML file generated from the conversion of a notebook.

post_process_latex

Modifies a latex file after its generation by sphinx.

post_process_latex_output

Postprocesses the latex file produced by sphinx.

post_process_latex_output_any

Postprocesses the latex file produced by sphinx.

post_process_python

Modifies a python file after its generation by sphinx.

post_process_python_output

Postprocesses the python file produced by sphinx.

post_process_rst_output

Processes a rst file generated from the conversion of a notebook.

post_process_slides_output

Processes a HTML file generated from the conversion of a notebook.

remove_character_under32

Removes ASCII characters in [0..31].

update_notebook_link

A notebook can contain a link [anchor](find://...) and it will be converted into: :ref:... in rst format.

Documentation

Contains the main function to generate the documentation for a module designed the same way as this one, generate_help_sphinx.

source on GitHub

pyquickhelper.helpgen.post_process._notebook_replacements(nbtext, notebook_replacements, fLOG=None)[source][source]

Makes some replacements in a notebook.

Parameters
  • nbtext – text to process

  • notebook_replacements – dictionary of replacements

  • fLOG – logging function

Returns

text

source on GitHub

pyquickhelper.helpgen.post_process.post_process_html_output(file, pdf, python, slides, exc=True, nblinks=None, fLOG=None, notebook_replacements=None)[source][source]

Processes a HTML file generated from the conversion of a notebook.

Parameters
  • file – filename

  • pdf – if True, add a link to the PDF, assuming it will exists at the same location

  • python – if True, add a link to the Python conversion

  • slides – if True, add a link to the slides conversion

  • exc – raises an exception (True) or a warning (False)

  • nblinks – dictionary {ref: url}

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

source on GitHub

pyquickhelper.helpgen.post_process.post_process_latex(st, doall, info=None, latex_book=False, exc=True, custom_latex_processing=None, nblinks=None, file=None, remove_unicode=False, fLOG=None, notebook_replacements=None)[source][source]

Modifies a latex file after its generation by sphinx.

Parameters
  • st – string

  • doall – do all transformations

  • info – for more understandable error messages

  • latex_book – customized for a book

  • exc – raises an exception or a warning

  • custom_latex_processing – function which takes and returns a string, final post processing

  • nblinks – dictionary {ref: url}

  • file – only used when an exception is raised

  • remove_unicode – remove unicode character (fails when converting into PDF)

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

Returns

string

SVG included in a notebook (or in RST file) usually do not word. Inkscape should be used to convert them into Latex. The function is less strict on the checking of $. The function replaces \mathbb{1} by \mathbf{1\!\!1}.

Why a ¿ is showing the final PDF?

Unicode, chinese characters are an issue because the latex compiler prompts on those if the necessary packages are not installed. pdflatex does not accepts inline chinese characters, xetex should be used instead: see How to input Traditional Chinese in pdfLaTeX. Until this is being implemented, the unicode will unfortunately be removed in this function.

Changed in version 1.9: Removes the uses of package parskip, it uses command \DeclareRelease which is not always recognized.

source on GitHub

pyquickhelper.helpgen.post_process.post_process_latex_output(root, doall, latex_book=False, exc=True, custom_latex_processing=None, nblinks=None, remove_unicode=True, fLOG=None, notebook_replacements=None)[source][source]

Postprocesses the latex file produced by sphinx.

Parameters
  • root – root path or latex file to process

  • doall – do all transformations

  • latex_book – customized for a book

  • exc – raises an exception or a warning

  • custom_latex_processing – function which does some post processing of the full latex file

  • nblinks – dictionary { ref : url } where to look for references

  • remove_unicode – remove unicode characters (fails with latex)

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

source on GitHub

pyquickhelper.helpgen.post_process.post_process_latex_output_any(file, custom_latex_processing, nblinks=None, remove_unicode=False, fLOG=None, notebook_replacements=None)[source][source]

Postprocesses the latex file produced by sphinx.

Parameters
  • file – latex filename

  • custom_latex_processing – function which does some post processing of the full latex file

  • nblinks – dictionary {url: link}

  • remove_unicode – remove unicode characters

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

source on GitHub

pyquickhelper.helpgen.post_process.post_process_python(st, doall, info=None, nblinks=None, file=None, fLOG=None, notebook_replacements=None)[source][source]

Modifies a python file after its generation by sphinx.

Parameters
  • st – string

  • doall – do all transformations

  • info – for more understandable error messages

  • nblinks – dictionary {ref: url}

  • file – used only when an exception is raised

  • fLOG – logging function

  • notebook_replacements – string replacement in notebooks

Returns

string

source on GitHub

pyquickhelper.helpgen.post_process.post_process_python_output(root, doall, exc=True, nblinks=None, fLOG=None, notebook_replacements=None)[source][source]

Postprocesses the python file produced by sphinx.

Parameters
  • root – root path or python file to process

  • doall – unused

  • exc – raise an exception if needed

  • nblinks – dictionary {ref: url}

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

source on GitHub

pyquickhelper.helpgen.post_process.post_process_rst_output(file, html, pdf, python, slides, is_notebook=False, exc=True, github=False, notebook=None, nblinks=None, fLOG=None, notebook_replacements=None)[source][source]

Processes a rst file generated from the conversion of a notebook.

Parameters
  • file – filename

  • pdf – if True, add a link to the pdf, assuming it will exists at the same location

  • html – if True, add a link to the html conversion

  • python – if True, add a link to the Python conversion

  • slides – if True, add a link to the slides conversion

  • is_notebook – does something more if the file is a notebook

  • exc – raises an exception (True) or a warning (False)

  • github – add a link to the notebook on github

  • notebook – location of the notebook, file might be a copy

  • nblinks – links added to a notebook, dictionary {ref: url}

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

Changed in version 1.7: Add this replacement: st = st.replace("\\mathbb{1}", "\\mathbf{1\\!\\!1}"). Checks that audio is only included in HTML.

source on GitHub

pyquickhelper.helpgen.post_process.post_process_slides_output(file, pdf, python, slides, exc=True, nblinks=None, fLOG=None, notebook_replacements=None)[source][source]

Processes a HTML file generated from the conversion of a notebook.

Parameters
  • file – filename

  • pdf – if True, add a link to the PDF, assuming it will exists at the same location

  • python – if True, add a link to the Python conversion

  • slides – if True, add a link to the slides conversion

  • exc – raises an exception (True) or a warning (False)

  • nblinks – dictionary {ref: url}

  • notebook_replacements – string replacement in notebooks

  • fLOG – logging function

source on GitHub

pyquickhelper.helpgen.post_process.remove_character_under32(s)[source][source]

Removes ASCII characters in [0..31].

Parameters

s – string to process

Returns

filtered string

source on GitHub

A notebook can contain a link [anchor](find://...) and it will be converted into: :ref:... in rst format.

Parameters
  • text – text to look into

  • format – format

  • nblinks – list of mappings (reference: url)

  • fLOG – logging function

Returns

modified text

source on GitHub