diff --git a/pom.xml b/pom.xml
index 1b68491..1efec02 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,5 +120,10 @@
scala-junction_2.9.1
0.1.0
+
+ org.yaml
+ snakeyaml
+ 2.1
+
diff --git a/src/main/java/org/metanorma/MetanormaCollectionManifest.java b/src/main/java/org/metanorma/MetanormaCollectionManifest.java
new file mode 100644
index 0000000..a54c7bc
--- /dev/null
+++ b/src/main/java/org/metanorma/MetanormaCollectionManifest.java
@@ -0,0 +1,103 @@
+package org.metanorma;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.*;
+import java.nio.file.Paths;
+import java.util.*;
+
+// To generate the collection manifest
+// see https://github.com/metanorma/annotated-express/issues/134
+public class MetanormaCollectionManifest {
+
+ List> inputOutputFiles;
+
+ Map yamlObj = new LinkedHashMap<>();
+
+ public MetanormaCollectionManifest(List> inputOutputFiles) {
+ this.inputOutputFiles = inputOutputFiles;
+ try {
+ Yaml yaml = new Yaml();
+ InputStream inputStream = Util.getStreamFromResources(stepmod2mn.class.getClassLoader(), "collection_template.yml");
+ yamlObj = yaml.load(inputStream);
+ //System.out.println(yamlObj);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ public void generate() throws IOException {
+ // get repository root folder from 1st file
+ String repositoryRootFolder = Util.getRepositoryRootFolder(inputOutputFiles.get(0).getValue());
+ if (!repositoryRootFolder.isEmpty()) {
+ int counter = 0;
+ for (Map.Entry entry : inputOutputFiles) {
+ String resultAdoc = entry.getValue();
+ String documentFolder = new File(resultAdoc).getParent();
+ File fileResultCollectionYml = Paths.get(documentFolder, "collection.yml").toFile();
+ InputStream is = new FileInputStream(fileResultCollectionYml);
+ Yaml yaml = new Yaml();
+ Map yamlDocumentObj = yaml.load(is);
+ //System.out.println(yamlDocumentObj);
+
+ // manifest:
+ // - level: document
+ update_docref(yamlDocumentObj,0, documentFolder);
+
+ // manifest:
+ // - level: attachments
+ update_docref(yamlDocumentObj,1, documentFolder);
+
+ counter++;
+ }
+
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ PrintWriter writer = new PrintWriter(Paths.get(repositoryRootFolder, "collection.yml").toFile());
+ yaml.dump(yamlObj, writer);
+ }
+ }
+
+ private void update_docref(Map yamlDocumentObj, int num, String documentFolder) {
+ ArrayList docref =
+ ((ArrayList