Fixed docs build system not to overwrite XML files

Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
diff --git a/docs/collect_examples.py b/docs/collect_examples.py
index 3bbc10c..77a8e92 100644
--- a/docs/collect_examples.py
+++ b/docs/collect_examples.py
@@ -101,7 +101,7 @@
                 tests.append((d, d_name,))
 
     # Process each test
-    check_ignore = ignore_patterns("*.v", "*.xml")
+    check_ignore = ignore_patterns("*.v", "golden.*.xml")
     for test_name, test_src in tests:
 
         test_rel = os.path.relpath(test_src, tests_dir)
diff --git a/docs/make_xml_for_docs.py b/docs/make_xml_for_docs.py
index 7f20257..1d4b1b1 100644
--- a/docs/make_xml_for_docs.py
+++ b/docs/make_xml_for_docs.py
@@ -81,27 +81,29 @@
 
         make_xml_for_docs(dep_file, dep_dir)
 
-    # Run V2X
+    # Run V2X, but only if an XML is not already provided
     vlog_mod = vlog_title.split(".")[0]
 
     model_file = os.path.join(output_dir, vlog_mod + ".model.xml")
     pbtype_file = os.path.join(output_dir, vlog_mod + ".pb_type.xml")
 
-    xml = vlog_to_model.vlog_to_model([vlog_dst], None, None, model_file)
-    with open(model_file, "w") as fp:
-        fp.write(xml)
+    if not os.path.isfile(model_file):
+        xml = vlog_to_model.vlog_to_model([vlog_dst], None, None, model_file)
+        with open(model_file, "w") as fp:
+            fp.write(xml)
 
-    xml = vtr_stylize_xml(model_file)
-    with open(model_file, "w") as fp:
-        fp.write(xml)
+        xml = vtr_stylize_xml(model_file)
+        with open(model_file, "w") as fp:
+            fp.write(xml)
 
-    xml = vlog_to_pbtype.vlog_to_pbtype([vlog_dst], pbtype_file, None)
-    with open(pbtype_file, "w") as fp:
-        fp.write(xml)
+    if not os.path.isfile(pbtype_file):
+        xml = vlog_to_pbtype.vlog_to_pbtype([vlog_dst], pbtype_file, None)
+        with open(pbtype_file, "w") as fp:
+            fp.write(xml)
 
-    xml = vtr_stylize_xml(pbtype_file)
-    with open(pbtype_file, "w") as fp:
-        fp.write(xml)
+        xml = vtr_stylize_xml(pbtype_file)
+        with open(pbtype_file, "w") as fp:
+            fp.write(xml)
 
 
 # =============================================================================