# Path: scripts/load_as_rst.py
# def convert(fname_in, fname_out=None, preamble=None, strict=False):
#     """
#     Converts an file at ``fname_in`` from a format understood by pypandoc
#     to ReStructuredText.
# 
#     :param fname_in:
#         Filename to read.
# 
#     :param fname_out:
#         Filename to write to - this will be overwritten. If unspecified,
#         the converted text is returned.
# 
#     :param preamble:
#         A preamble to add to the file (e.g. "#This is an auto-generated file")
#     """
#     if fname_in is None:
#         raise ValueError('Must specify an input file')
# 
#     if not os.path.exists(fname_in):
#         raise IOError('File not found: {}'.format(fname_in))
# 
#     text = preamble or ''
#     text = '\n'.join((text, load_text(fname_in, strict=strict)))
# 
#     if fname_out is not None:
#         with open(fname_out, 'w') as f:
#             print(text, file=f)
# 
#         return None         # Just being explicit
#     else:
#         return text


import sys
import os
from setuptools_scm import get_version
from scripts.load_as_rst import convert

# Scale large images.
#epub_max_image_width = 0

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#epub_show_urls = 'inline'

# If false, no index is generated.
#epub_use_index = True


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

autodoc_member_order = 'bysource'
# ------------------  Auto generation -------------------
# Automatically generate README.rst in the source directory (done in a generic
# way so it's easy to include other .md files)
#
# Change strict_conversion to False if you want to allow documentation to build
# without converting RST to MD
strict_conversion = True
preamble_fmt = \
"""
.. This file automatically generated during build from {file_in}. Any changes
   made to this file will be overwritten.
"""

convert_files = {'../../README.md': 'README.rst'}
for file_in, file_out in convert_files.items():

# Path: scripts/load_as_rst.py
# def convert(fname_in, fname_out=None, preamble=None, strict=False):
#     """
#     Converts an file at ``fname_in`` from a format understood by pypandoc
#     to ReStructuredText.
# 
#     :param fname_in:
#         Filename to read.
# 
#     :param fname_out:
#         Filename to write to - this will be overwritten. If unspecified,
#         the converted text is returned.
# 
#     :param preamble:
#         A preamble to add to the file (e.g. "#This is an auto-generated file")
#     """
#     if fname_in is None:
#         raise ValueError('Must specify an input file')
# 
#     if not os.path.exists(fname_in):
#         raise IOError('File not found: {}'.format(fname_in))
# 
#     text = preamble or ''
#     text = '\n'.join((text, load_text(fname_in, strict=strict)))
# 
#     if fname_out is not None:
#         with open(fname_out, 'w') as f:
#             print(text, file=f)
# 
#         return None         # Just being explicit
#     else:
#         return text


# Path: docs/source/conf.py
import sys
import os
from setuptools_scm import get_version
from scripts.load_as_rst import convert


# Scale large images.
#epub_max_image_width = 0

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#epub_show_urls = 'inline'

# If false, no index is generated.
#epub_use_index = True


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

autodoc_member_order = 'bysource'
# ------------------  Auto generation -------------------
# Automatically generate README.rst in the source directory (done in a generic
# way so it's easy to include other .md files)
#
# Change strict_conversion to False if you want to allow documentation to build
# without converting RST to MD
strict_conversion = True
preamble_fmt = \
"""
.. This file automatically generated during build from {file_in}. Any changes
   made to this file will be overwritten.
"""

convert_files = {'../../README.md': 'README.rst'}
for file_in, file_out in convert_files.items():

    convert(file_in, file_out,