From 7a68bcc784b139043c094dd4bf653c0cdee8ccb7 Mon Sep 17 00:00:00 2001 From: shab5 <95657217+shab5@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:38:10 -0700 Subject: [PATCH] Export docs for bloqs without examples --- dev_tools/ui-export.ipynb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/dev_tools/ui-export.ipynb b/dev_tools/ui-export.ipynb index c1d9d416f..18c552af7 100644 --- a/dev_tools/ui-export.ipynb +++ b/dev_tools/ui-export.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -45,12 +45,13 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import attrs\n", "import hashlib\n", + "import json\n", "\n", "from qualtran import CompositeBloq\n", "from qualtran.bloqs.rotations.programmable_rotation_gate_array import ProgrammableRotationGateArray\n", @@ -71,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -108,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -132,13 +133,6 @@ " for child_bloq, _ in call_graph.succ[bloq].items():\n", " write_example(child_bloq)\n", "\n", - " Path(f'ui_export/{bloq.__class__.__name__}').mkdir(parents=True, exist_ok=True)\n", - "\n", - " doc_name = f'ui_export/{bloq.__class__.__name__}/docs.txt'\n", - " if not os.path.isfile(doc_name):\n", - " with open(doc_name, 'w') as doc_file:\n", - " doc_file.write('\\n'.join(get_markdown_docstring(bloq.__class__)))\n", - "\n", " file_name = f'ui_export/{bloq.__class__.__name__}/{bloq_filename(bloq)}'\n", " if not os.path.isfile(file_name):\n", " bloq_dict = {\n", @@ -160,6 +154,13 @@ "for section in NB_BY_SECTION:\n", " for notebook_spec in section[1]:\n", " for bloq_spec in notebook_spec.bloq_specs:\n", + " Path(f'ui_export/{bloq_spec.bloq_cls.__name__}').mkdir(parents=True, exist_ok=True)\n", + "\n", + " doc_name = f'ui_export/{bloq_spec.bloq_cls.__name__}/docs.txt'\n", + " if not os.path.isfile(doc_name):\n", + " with open(doc_name, 'w') as doc_file:\n", + " doc_file.write('\\n'.join(get_markdown_docstring(bloq_spec.bloq_cls)))\n", + "\n", " for example in bloq_spec.examples:\n", " write_example(example.make())" ]