[Populate] Added support to compress and Makefile generation
This commit is contained in:
parent
b0a395e68a
commit
171803ff64
|
|
@ -160,16 +160,26 @@ class CompressOptions(BaseOptions):
|
|||
logger.error('Unknown output `{}` selected in {}'.format(f.from_output, self._parent))
|
||||
exit(WRONG_ARGUMENTS)
|
||||
if not no_out_run:
|
||||
extra_files = []
|
||||
for file in files_list:
|
||||
if not os.path.isfile(file):
|
||||
if not os.path.exists(file):
|
||||
# The target doesn't exist
|
||||
if not out._done:
|
||||
# The output wasn't created in this run, try running it
|
||||
run_output(out)
|
||||
if not os.path.isfile(file):
|
||||
if not os.path.exists(file):
|
||||
# Still missing, something is wrong
|
||||
logger.error('Unable to generate `{}` from {}'.format(file, out))
|
||||
exit(INTERNAL_ERROR)
|
||||
if os.path.isdir(file):
|
||||
# Popultate output adds the image dirs
|
||||
# Computing its content is complex:
|
||||
# - We must parse the input markdown
|
||||
# - We must coinfigure and use the renderer output to do the file name expansion
|
||||
# This is almost as complex as generating the whole output, so it adds the dir
|
||||
extra_files = glob.iglob(os.path.join(file, '**'))
|
||||
if extra_files:
|
||||
files_list += extra_files
|
||||
else:
|
||||
out_dir = out_dir_cwd if f.from_cwd else out_dir_default
|
||||
source = f.expand_filename_both(f.source, make_safe=False)
|
||||
|
|
|
|||
|
|
@ -75,8 +75,12 @@ class PopulateOptions(VariantOptions):
|
|||
if '%d' not in self.imgname:
|
||||
raise KiPlotConfigurationError('The image pattern must contain `%d` `{}`'.format(self.imgname))
|
||||
|
||||
# def get_targets(self, out_dir):
|
||||
# return [self._parent.expand_filename(out_dir, self.output)]
|
||||
def get_out_file_name(self):
|
||||
return 'index.html' if self.format == 'html' else 'index.md'
|
||||
|
||||
def get_targets(self, out_dir):
|
||||
img_dir = os.path.dirname(self._parent.expand_filename(out_dir, self.imgname))
|
||||
return [self._parent.expand_filename(out_dir, self.get_out_file_name()), img_dir]
|
||||
|
||||
def generate_image(self, side, components, active_components, name):
|
||||
options = self._renderer.options
|
||||
|
|
@ -167,7 +171,7 @@ class PopulateOptions(VariantOptions):
|
|||
raise KiPlotConfigurationError('Failed to load file `{}`'.format(template_file))
|
||||
# Initialize the output file renderer
|
||||
renderer = create_renderer(self.format, self.initial_components)
|
||||
outputfile = 'index.html' if is_html else 'index.md'
|
||||
outputfile = self.get_out_file_name()
|
||||
# Parse the input markdown
|
||||
parsed_content = parse_content(renderer, content)
|
||||
logger.debugl(3, parsed_content)
|
||||
|
|
@ -197,8 +201,3 @@ class Populate(BaseOutput): # noqa: F821
|
|||
self.options = PopulateOptions
|
||||
""" *[dict] Options for the `populate` output """
|
||||
self._category = 'PCB/docs'
|
||||
|
||||
# def get_dependencies(self):
|
||||
|
||||
# @staticmethod
|
||||
# def get_conf_examples(name, layers, templates):
|
||||
|
|
|
|||
|
|
@ -76,3 +76,10 @@ outputs:
|
|||
options:
|
||||
renderer: PcbDraw
|
||||
input: tests/data/source_html.md
|
||||
|
||||
- name: Compressed
|
||||
comment: "Compress the result"
|
||||
type: compress
|
||||
options:
|
||||
files:
|
||||
- from_output: Populate
|
||||
|
|
|
|||
Loading…
Reference in New Issue