diff --git a/protoscribe/evolution/make_html.py b/protoscribe/evolution/make_html.py
index af42c19..61a0cf2 100644
--- a/protoscribe/evolution/make_html.py
+++ b/protoscribe/evolution/make_html.py
@@ -25,21 +25,19 @@
import os
_EXTENSIONS_FILE = flags.DEFINE_string(
- "extensions_file", None,
+ "extensions_file", "",
"Path to the text file in TSV format containing glyph extensions.",
- required=True
-)
-
-_OUTPUT_HTML_DIR = flags.DEFINE_string(
- "output_html_dir", None,
- "Path to output directory for `index.html`.",
- required=True
)
_SVG_SRC_DIR = flags.DEFINE_string(
- "svg_src_dir", None,
+ "svg_src_dir", "",
"Directory containing source graphics in SVG format for the glyph "
"extensions.",
+)
+
+_OUTPUT_HTML_DIR = flags.DEFINE_string(
+ "output_html_dir", None,
+ "Path to output directory for `index.html`.",
required=True
)
@@ -150,8 +148,12 @@ def make_html() -> None:
os.makedirs(output_svg_dir, exist_ok=True)
# Create index page.
+ if not _EXTENSIONS_FILE.value:
+ raise ValueError("Specify --extensions_file!")
concepts = _compose_page(_EXTENSIONS_FILE.value, _OUTPUT_HTML_DIR.value)
# Copy graphics.
+ if not _SVG_SRC_DIR.value:
+ raise ValueError("Specify --svg_src_dir!")
logging.info("Copying %d SVGs from %s ...", len(concepts), _SVG_SRC_DIR.value)
_copy_svgs(concepts, _SVG_SRC_DIR.value, output_svg_dir)
diff --git a/protoscribe/evolution/stages/make_html_main.py b/protoscribe/evolution/stages/make_html_main.py
new file mode 100644
index 0000000..f7d6867
--- /dev/null
+++ b/protoscribe/evolution/stages/make_html_main.py
@@ -0,0 +1,69 @@
+# Copyright 2024 The Protoscribe Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+r"""Helper script for generating HTML page with results.
+
+This tool is only relevant for sketch generation.
+
+Example:
+--------
+ BASE_DIR=...
+ python protoscribe/evolution/stages/make_html_main.py \
+ --default_base_dir="${BASE_DIR} \
+ --experiment_name="concept_to_glyph" \
+ --round=0 \
+ --output_html_dir=/tmp \
+ --logtostderr
+"""
+
+from collections.abc import Sequence
+import logging
+import os
+
+from absl import app
+from absl import flags
+from protoscribe.evolution import make_html
+from protoscribe.evolution.stages import common_flags
+
+_EXPERIMENT_NAME = flags.DEFINE_string(
+ "experiment_name", None,
+ "An experiment name which will define the directory in which the "
+ "evolving system data is placed.",
+ required=True
+)
+
+FLAGS = flags.FLAGS
+
+
+def main(argv: Sequence[str]) -> None:
+ if len(argv) > 1:
+ raise app.UsageError("Too many command-line arguments.")
+
+ # Infer the locations of source SVGs and glyph extension names.
+ base_dir = common_flags.experiment_dir()
+ svg_src_dir = os.path.join(base_dir, "glyph_extensions_svg")
+ round_data_dir = common_flags.round_data_dir()
+ logging.info("Using data location: %s", round_data_dir)
+ extensions_tsv_file = os.path.join(
+ round_data_dir, "inference_extensions", "extensions.tsv"
+ )
+
+ # Override the source flags and invoke the HTML builder.
+ FLAGS.extensions_file = extensions_tsv_file
+ FLAGS.svg_src_dir = svg_src_dir
+ make_html.make_html()
+
+
+if __name__ == "__main__":
+ app.run(main)