# -*- coding: utf-8 -*- """ Format the readme.md file into the sphinx index.rst file. """ from __future__ import absolute_import, division, print_function import os import inspect import re import pypandoc from astropy.time import Time from pyuvdata.version import construct_version_info def write_index_rst(readme_file=None, write_file=None): t = Time.now() t.out_subfmt = 'date' out = ('.. pyuvdata documentation master file, created by\n' ' make_index.py on {date}\n\n').format(date=t.iso) if readme_file is None: main_path = os.path.dirname(os.path.dirname(os.path.abspath(inspect.stack()[0][1]))) readme_file = os.path.join(main_path, 'README.md') readme_text = pypandoc.convert_file(readme_file, 'rst') title_badge_text = ( 'pyuvdata\n========\n\n' '.. image:: https://circleci.com/gh/RadioAstronomySoftwareGroup/pyuvdata.svg?style=svg\n' ' :target: https://circleci.com/gh/RadioAstronomySoftwareGroup/pyuvdata\n\n' '.. image:: https://dev.azure.com/radioastronomysoftwaregroup/pyuvdata/_apis/build/status/RadioAstronomySoftwareGroup.pyuvdata?branchName=master\n' ' :target: https://dev.azure.com/radioastronomysoftwaregroup/pyuvdata/_build/latest?definitionId=1&branchName=master\n\n' '.. image:: https://codecov.io/gh/RadioAstronomySoftwareGroup/pyuvdata/branch/master/graph/badge.svg\n' ' :target: https://codecov.io/gh/RadioAstronomySoftwareGroup/pyuvdata\n\n' '.. image:: http://joss.theoj.org/papers/10.21105/joss.00140/status.svg\n' ' :target: https://doi.org/10.21105/joss.00140\n\n') begin_desc = 'pyuvdata defines a pythonic interface' start_desc = str.find(readme_text, begin_desc) readme_text = readme_text[start_desc:] # convert relative links in readme to explicit links version_info = construct_version_info() branch = version_info['git_branch'] readme_text = readme_text.replace( '