def presentation(config_file=None, md_file=None, serve=None, port=None, host=None, template=None, **template_args): """ MOOSE markdown presentation blaster. """ # Load the YAML configuration file config = MooseDocs.load_config(config_file, template=template, template_args=template_args) parser = MooseDocs.MooseMarkdown(extensions=config.keys(), extension_configs=config) site_dir, _ = os.path.splitext(md_file) if not os.path.isdir(site_dir): os.mkdir(site_dir) root = PresentationBuilder(name='', markdown=md_file, parser=parser, site_dir=site_dir) root.build() if serve: server = livereload.Server() server.watch(md_file, root.build) server.serve(root=site_dir, host=host, port=port, restart_delay=0) return None
def setUp(self): # clear site directory for root, _, files in os.walk('site'): for filename in files: if filename.endswith('.html'): os.remove(os.path.join(root, filename)) # Markdown parser self._parser = MooseDocs.MooseMarkdown()
def latex(config_file=None, output=None, md_file=None, **kwargs): """ Command for converting markdown file to latex. """ # Load the YAML configuration file config = MooseDocs.load_config(config_file, **kwargs) parser = MooseDocs.MooseMarkdown(extensions=config.keys(), extension_configs=config) site_dir, _ = os.path.splitext(md_file) root = LatexBuilder(output, name='', markdown=md_file, parser=parser, site_dir=site_dir) root.build() return None
def setUpClass(cls): """ Create the markdown parser using the configuration file. """ # Define the local directory cls._path = os.path.abspath(os.path.dirname(inspect.getfile(cls))) # Create the markdown object os.chdir(os.path.join(MooseDocs.MOOSE_DIR, 'docs')) # Read the YAML configurations config = MooseDocs.load_config(cls.CONFIG) # Update extension list if cls.EXTENSIONS: for key in config: if key not in cls.EXTENSIONS: config.pop(key) cls.updateExtensions(config) cls.parser = MooseDocs.MooseMarkdown(extensions=config.keys(), extension_configs=config) os.chdir(cls.WORKING_DIR)
def build(config_file=None, site_dir=None, num_threads=None, no_livereload=False, clean=False, serve=False, host=None, port=None, **kwargs): """ The main build command. """ if serve: clean = True site_dir = os.path.abspath(os.path.join(MooseDocs.TEMP_DIR, 'site')) # Clean/create site directory if clean and os.path.exists(site_dir): LOG.info('Cleaning build directory: %s', site_dir) shutil.rmtree(site_dir) # Create the "temp" directory if not os.path.exists(site_dir): os.makedirs(site_dir) # Load the YAML configuration file config = MooseDocs.load_config(config_file, **kwargs) # Create the markdown parser parser = MooseDocs.MooseMarkdown(extensions=config.keys(), extension_configs=config) # Create object for storing pages to be generated def build_complete(): """Builds complete documentation.""" builder = Builder(parser, site_dir) builder.build(num_threads=num_threads) return builder builder = build_complete() # Serve if serve: # Create the live server server = livereload.Server() # Watch markdown files if not no_livereload: for page in builder: server.watch(page.source(), page.build) # Watch support directories server.watch(os.path.join(os.getcwd(), 'media'), builder.copyFiles) server.watch(os.path.join(os.getcwd(), 'css'), builder.copyFiles) server.watch(os.path.join(os.getcwd(), 'js'), builder.copyFiles) server.watch(os.path.join(os.getcwd(), 'fonts'), builder.copyFiles) # Watch the files and directories that require complete rebuild server.watch(config_file, build_complete) server.watch('templates', builder.build) # Start the server server.serve(root=site_dir, host=host, port=port, restart_delay=0) return None