def main(): args = parse_args() if args.update: release = updater.get_latest_release() if release.version > __version_info__: updater.install_update(release.download_url, False) else: print("ficdl is up to date") sys.exit(0) try: pypandoc.ensure_pandoc_installed(delete_installer=True) except OSError: print( 'Could not find or install pandoc, install it from https://pandoc.org/ and try again.', file=sys.stderr) sys.exit(COULD_NOT_INSTALL_PANDOC) if args.verbose: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) if args.url is None: gui_main() else: cli_main(args)
def build(working_directory, configuration): """ Preprocess READEME.rst Doxygen doesn't support the importation of .rst files, and the support for .md files doesn't support images that also have links. To get around this limitation, this preprocessor will use docutils to convert the README.rst into an html file which will be directly imported into the Doxygen documentation so only one copy of the README is needed. On exit, return 0 for no error, or a non zero error code if there was an error to report. Args: working_directory Directory this script resides in. configuration Configuration to build, ``all`` if no configuration was requested. Returns: None if not implemented, otherwise an integer error code. """ # Copy README.rst to docs/temp/README.html # Doxygen may not create the output folder, ensure it exists. temp_dir = os.path.join(working_directory, 'temp') create_folder_if_needed(temp_dir) # Get the input and output file names source = os.path.join(os.path.dirname(working_directory), 'README.rst') dest = os.path.join(temp_dir, 'README.html') # Was the file already created and newer than the source? if is_source_newer(source, dest): # Load pandoc if needed to do the conversion if hasattr(pypandoc, 'ensure_pandoc_installed'): # pylint: disable=E1101 pypandoc.ensure_pandoc_installed(quiet=True, delete_installer=True) else: try: pypandoc.get_pandoc_path() except OSError: pypandoc.download_pandoc() pypandoc.convert_file(source, to='html', outputfile=dest) return 0
def convertMarkdownDocsToRst(): pypandoc.ensure_pandoc_installed() # TODO make various edits to improve conversion, like removing the Table of Contents print("Converting all .md files to .rst...") input_dir = '../../doc' output_dir = 'generated_docs' subdirs = ['', 'how_tos', 'explanations'] for subdir in subdirs: # print(f'>>>> {subdir}') input_sub_dir = f'{input_dir}/{subdir}' if not os.path.isdir(input_sub_dir): print(f'Directory {input_sub_dir} does not exist. Skipping)') output_sub_dir = f'{output_dir}/{subdir}' convert_all_markdown_files_in_dir(subdir, input_sub_dir, output_sub_dir)
def ensure_pandoc_installed(_): import pypandoc # Download pandoc if necessary. If pandoc is already installed and on # the PATH, the installed version will be used. Otherwise, we will # download a copy of pandoc into docs/bin/ and add that to our PATH. pandoc_dir = os.path.join(DOCS_DIRECTORY, "bin") # Add if pandoc_dir not in os.environ["PATH"].split(os.pathsep): os.environ["PATH"] += os.pathsep + pandoc_dir if hasattr(pypandoc, "ensure_pandoc_installed"): pypandoc.ensure_pandoc_installed( quiet=True, targetfolder=pandoc_dir, delete_installer=True, ) else: pypandoc.download_pandoc(targetfolder=pandoc_dir)
def build_readme(working_directory): """ Preprocess READEME.rst Doxygen doesn't support the importation of .rst files, and the support for .md files doesn't support images that also have links. To get around this limitation, this preprocessor will use docutils to convert the README.rst into an html file which will be directly imported into the Doxygen documentation so only one copy of the README is needed. Arg: working_directory: Directory for this function to build. Returns: Zero on no error, non-zero on error. """ # Copy README.rst to docs/temp/README.html # Doxygen may not create the output folder, ensure it exists. temp_dir = os.path.join(working_directory, 'temp') burger.create_folder_if_needed(temp_dir) # Get the input and output file names source = os.path.join(os.path.dirname(working_directory), 'README.rst') dest = os.path.join(temp_dir, 'README.html') # Was the file already created and newer than the source? if burger.is_source_newer(source, dest): # Load pandoc if needed to do the conversion if hasattr(pypandoc, 'ensure_pandoc_installed'): # pylint: disable=E1101 pypandoc.ensure_pandoc_installed(quiet=True, delete_installer=True) else: try: pypandoc.get_pandoc_path() except OSError: pypandoc.download_pandoc() pypandoc.convert_file(source, to='html', outputfile=dest) return 0
yield from extract_checkbox_arguments_from_request() yield "--input" yield os.path.join(directory, "ItemsDeliveredRawReport.csv") yield "--output" yield os.path.join(directory, "toetsanalyse.md") if "cesuur" in request.form: try: cesuur = float(request.form["cesuur"]) yield "--cesuur" yield str(cesuur) except ValueError: pass if "plot" in request.form: yield "--plot-dir" yield directory if "output-format" in request.form and request.form[ "output-format"] == "pdf": yield "--plot-extension" yield "pdf" if __name__ == "__main__": pypandoc.ensure_pandoc_installed() app.run(host='0.0.0.0', port=os.getenv('PORT', 8080), debug=True)