Skip to content

Commit

Permalink
Merge pull request strictdoc-project#1484 from strictdoc-project/stan…
Browse files Browse the repository at this point in the history
…islaw/speed_up_update_requirement

export/html: relax update_requirement by only regenerating the updated document itself
  • Loading branch information
stanislaw authored Nov 24, 2023
2 parents 6fc080c + d7aadd7 commit d73e28e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% assert custom_html2pdf_template is defined %}

<div
html2pdf-preloader
class="main"
Expand Down Expand Up @@ -38,7 +40,7 @@
</div>
</div>

{% if custom_html2pdf_template is not defined %}
{% if custom_html2pdf_template is none %}
{%- include "screens/document/pdf/template/frontpage.jinja" -%}
{%- include "screens/document/pdf/template/header.jinja" -%}
{%- include "screens/document/pdf/template/footer.jinja" -%}
Expand Down
34 changes: 28 additions & 6 deletions strictdoc/server/routers/main_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,28 @@ async def create_requirement(request: Request):
)
transform.perform()

# Saving new content to .SDoc file.
# Update the index because other documents might reference this
# document's sections. These documents will be regenerated on demand,
# when they are opened next time.
export_action.traceability_index.update_last_updated()

# Saving new content to .SDoc files.
document.ng_needs_generation = True
document_content = SDWriter().write(document)
document_meta = document.meta
with open(
document_meta.input_doc_full_path, "w", encoding="utf8"
) as output_file:
output_file.write(document_content)

# Re-exporting HTML files.
export_action.export()
# Exporting the updated document to HTML. Note that this happens after
# the traceability index last update marker has been updated. This way
# the generated HTML file is newer than the traceability index.
html_generator.export_single_document_with_performance(
document=document,
traceability_index=export_action.traceability_index,
specific_documents=(DocumentType.DOCUMENT,),
)

# Rendering back the Turbo template.
template = env().get_template(
Expand Down Expand Up @@ -1105,6 +1117,11 @@ async def document__update_requirement(request: Request):
)
result: UpdateRequirementResult = update_command.perform()

# Update the index because other documents might reference this
# document's sections. These documents will be regenerated on demand,
# when they are opened next time.
export_action.traceability_index.update_last_updated()

# Saving new content to .SDoc files.
document.ng_needs_generation = True
document_content = SDWriter().write(document)
Expand All @@ -1114,9 +1131,14 @@ async def document__update_requirement(request: Request):
) as output_file:
output_file.write(document_content)

# Re-exporting HTML files.
# Those with @ng_needs_generation == True will be regenerated.
export_action.export()
# Exporting the updated document to HTML. Note that this happens after
# the traceability index last update marker has been updated. This way
# the generated HTML file is newer than the traceability index.
html_generator.export_single_document_with_performance(
document=document,
traceability_index=export_action.traceability_index,
specific_documents=(DocumentType.DOCUMENT,),
)

iterator: DocumentCachingIterator = (
export_action.traceability_index.get_document_iterator(document)
Expand Down

0 comments on commit d73e28e

Please sign in to comment.