Skip to content

Commit

Permalink
Merge pull request #7 from robotpy/black
Browse files Browse the repository at this point in the history
Format with black
  • Loading branch information
virtuald committed Dec 26, 2018
2 parents 82f5f45 + 77ade1a commit 5e68a73
Show file tree
Hide file tree
Showing 22 changed files with 1,266 additions and 1,096 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ install:
script:
- tests/run_tests.sh

jobs:
include:
- stage: format-check
python:
- "3.6"
install:
- pip install black
script:
- black --check --diff .

deploy:
- provider: pypi
user: $PYPI_USERNAME
Expand Down
76 changes: 37 additions & 39 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,71 @@

# Insert module path here
sys.path.insert(0, abspath(dirname(__file__)))
sys.path.insert(0, abspath(join(dirname(__file__), '..')))
sys.path.insert(0, abspath(join(dirname(__file__), "..")))

import navx

# -- RTD configuration ------------------------------------------------

# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

# This is used for linking and such so we link to the thing we're building
rtd_version = os.environ.get('READTHEDOCS_VERSION', 'latest')
if rtd_version not in ['stable', 'latest']:
rtd_version = 'stable'
rtd_version = os.environ.get("READTHEDOCS_VERSION", "latest")
if rtd_version not in ["stable", "latest"]:
rtd_version = "stable"

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx'
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.intersphinx"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'robotpy-navx'
copyright = '2015, RobotPy development team'
project = "robotpy-navx"
copyright = "2015, RobotPy development team"

intersphinx_mapping = {
'wpilib': ('http://robotpy-wpilib.readthedocs.org/en/%s/' % rtd_version, None),
"wpilib": ("http://robotpy-wpilib.readthedocs.org/en/%s/" % rtd_version, None)
}

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '.'.join(navx.__version__.split('.')[:2])
version = ".".join(navx.__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags.
release = navx.__version__

autoclass_content = 'both'
autoclass_content = "both"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# -- Options for HTML output ----------------------------------------------

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
else:
html_theme = 'default'
html_theme = "default"

# Output file base name for HTML help builder.
htmlhelp_basename = 'sphinxdoc'
htmlhelp_basename = "sphinxdoc"

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -84,43 +81,44 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'sphinx.tex', '. Documentation',
'Author', 'manual'),
]
latex_documents = [("index", "sphinx.tex", ". Documentation", "Author", "manual")]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'sphinx', '. Documentation',
['Author'], 1)
]
man_pages = [("index", "sphinx", ". Documentation", ["Author"], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'sphinx', '. Documentation',
'Author', 'sphinx', 'One line description of project.',
'Miscellaneous'),
(
"index",
"sphinx",
". Documentation",
"Author",
"sphinx",
"One line description of project.",
"Miscellaneous",
)
]

# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = '.'
epub_author = 'Author'
epub_publisher = 'Author'
epub_copyright = '2015, Author'
epub_title = "."
epub_author = "Author"
epub_publisher = "Author"
epub_copyright = "2015, Author"

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]

# -- Custom Document processing ----------------------------------------------

import gensidebar
gensidebar.generate_sidebar(globals(), 'navx')

gensidebar.generate_sidebar(globals(), "navx")
113 changes: 59 additions & 54 deletions docs/gensidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,91 @@

import os


def write_if_changed(fname, contents):

try:
with open(fname, 'r') as fp:
with open(fname, "r") as fp:
old_contents = fp.read()
except:
old_contents = ''
old_contents = ""

if old_contents != contents:
with open(fname, 'w') as fp:
with open(fname, "w") as fp:
fp.write(contents)


def generate_sidebar(conf, conf_api):

# determine 'latest' or 'stable'
# if not conf.do_gen:
do_gen = os.environ.get('SIDEBAR', None) == '1' or conf['on_rtd']
version = conf['rtd_version']

lines = [
'', '.. DO NOT MODIFY! THIS PAGE IS AUTOGENERATED!', ''
]

do_gen = os.environ.get("SIDEBAR", None) == "1" or conf["on_rtd"]
version = conf["rtd_version"]

lines = ["", ".. DO NOT MODIFY! THIS PAGE IS AUTOGENERATED!", ""]

def toctree(name):
lines.extend(['.. toctree::',
' :caption: %s' % name,
' :maxdepth: 2',
''])

lines.extend(
[".. toctree::", " :caption: %s" % name, " :maxdepth: 2", ""]
)

def endl():
lines.append('')
lines.append("")

def write(desc, link):
if conf_api == 'robotpy':
if conf_api == "robotpy":
args = desc, link
elif not do_gen:
return
else:
args = desc, 'https://robotpy.readthedocs.io/en/%s/%s.html' % (version, link)

lines.append(' %s <%s>' % args)

args = (
desc,
"https://robotpy.readthedocs.io/en/%s/%s.html" % (version, link),
)

lines.append(" %s <%s>" % args)

def write_api(project, desc):
if project != conf_api:
if do_gen:
args = desc, project, version
lines.append(' %s API <https://robotpy.readthedocs.io/projects/%s/en/%s/api.html>' % args)
lines.append(
" %s API <https://robotpy.readthedocs.io/projects/%s/en/%s/api.html>"
% args
)
else:
lines.append(' %s API <api>' % desc)
lines.append(" %s API <api>" % desc)

#
# Specify the sidebar contents here
#
toctree('Robot Programming')
write('Getting Started', 'getting_started')
write('Installation', 'install/index')
write("Programmer's Guide", 'guide/index')
write('Frameworks', 'frameworks/index')
write('Hardware & Sensors', 'hw')
write('Camera & Vision', 'vision/index')

toctree("Robot Programming")
write("Getting Started", "getting_started")
write("Installation", "install/index")
write("Programmer's Guide", "guide/index")
write("Frameworks", "frameworks/index")
write("Hardware & Sensors", "hw")
write("Camera & Vision", "vision/index")
endl()
toctree('API Reference')
write_api('wpilib', 'WPILib')
write_api('pynetworktables', 'NetworkTables')
write_api('utilities', 'Utilities')
write_api('pyfrc', 'PyFRC')
write_api('ctre', 'CTRE Libraries')
write_api('navx', 'NavX Library')

toctree("API Reference")
write_api("wpilib", "WPILib")
write_api("pynetworktables", "NetworkTables")
write_api("utilities", "Utilities")
write_api("pyfrc", "PyFRC")
write_api("ctre", "CTRE Libraries")
write_api("navx", "NavX Library")
endl()
toctree('Additional Info')
write("Troubleshooting", 'troubleshooting')
write('Support', 'support')
write('FAQ', 'faq')

toctree("Additional Info")
write("Troubleshooting", "troubleshooting")
write("Support", "support")
write("FAQ", "faq")
endl()
toctree('RobotPy Developers')
write('Developer Documentation', 'dev/index')

toctree("RobotPy Developers")
write("Developer Documentation", "dev/index")
endl()
write_if_changed('_sidebar.rst.inc', '\n'.join(lines))

write_if_changed("_sidebar.rst.inc", "\n".join(lines))
3 changes: 1 addition & 2 deletions navx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

try:
from .version import __version__
except ImportError:
__version__ == 'master'
__version__ == "master"

from .ahrs import AHRS
from .pins import *
1 change: 0 additions & 1 deletion navx/_impl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from .ahrsprotocol import AHRSProtocol
from .imuprotocol import IMUProtocol
from .imuregisters import IMURegisters

0 comments on commit 5e68a73

Please sign in to comment.