docs: def read_file_snippets(file, snippet_store):
      """Parse a file and add all snippets to the snippet_store dictionary"""
      start_reg = re.compile("(.*%%SNIPPET_START%% )([a-zA-Z0-9]+)")
      end_reg = re.compile("(.*%%SNIPPET_END%% )([a-zA-Z0-9]+)")
      open_snippets = {}
      with open(file, encoding="utf-8") as w:
          lines = w.readlines()
  
          for line in lines:
              printd("Got Line: {}".format(line))
              # Check whether we're entering or leaving a snippet
              m = start_reg.match(line)
              if m:
                  printd("Opened Snippet {}".format(m.group(2)))
                  if m.group(2) in snippet_store:
                      record_error("Repeat definition of Snippet {}".format(m.group(2)))
                  elif m.group(2) in open_snippets:
                      record_error("Snippet already opened {}".format(m.group(2)))
                  else:
                      printd("Added {} to open snippets list".format(m.group(2)))
                      open_snippets[m.group(2)] = []
                  continue
  
              m = end_reg.match(line)
              if m:
                  printd("Found end of Snippet {}".format(m.group(2)))
                  if m.group(2) not in open_snippets:
                      record_error("Reached Snippet End but no start")
                  elif m.group(2) in snippet_store:
                      record_error("Repeat definition of Snippet {}".format(m.group(2)))
                  else:
                      snippet_store[m.group(2)] = open_snippets[m.group(2)]
                      del open_snippets[m.group(2)]
                  continue
  
              # If we've got this far, then we're just a normal line, so we can add this to all open snippets
              for snippet in open_snippets.values():
                  printd("Adding Line to snippet")
                  snippet.append(line)
  
          # Now, warn about any unclosed snippets
          for opened in open_snippets:
              record_error("Snippet {} left open - ignoring".format(opened))