docs: def main():
      '''Main routine.'''
      # validate command line arguments
      arg_parser = argparse.ArgumentParser()
  
      arg_parser.add_argument('--sourcedir', '-s', required=True, action='store',
                              help='Source folder containing python files.')
      arg_parser.add_argument('--docfile', '-o', required=True, action='store',
                              help='Name of markdown file to write output to.')
      arg_parser.add_argument('--projectname', '-n', required=False, action='store',
                              help='Project name (optional, otherwise sourcedir will be used).')
      arg_parser.add_argument('--codelinks', '-c', required=False, action='store_true',
                              help='Include links to source files (optional).')
  
      args = arg_parser.parse_args()
  
      source_dir = args.sourcedir
      doc_file = args.docfile
      code_links = args.codelinks
      proj_name = args.projectname
      if proj_name is None:
          proj_name = source_dir
  
      # main document dictionary
      meta_doc = {'header': proj_name + ' Technical Reference Guide'}
      meta_doc['modules'] = []
  
      # process each file
      for source_file in glob.glob(source_dir + '/*.py'):
          if '__' in source_file:
              print('Skipping: ' + source_file)
              continue
          file_meta_doc = process_file(source_file)
          meta_doc['modules'].append(file_meta_doc)
  
      # create output file
      process_output(meta_doc, doc_file, code_links)