Clean up configuration files

This commit is contained in:
PeridexisErrant 2015-10-22 09:48:05 +11:00
parent 4b48c4effb
commit 5c16aca447
3 changed files with 24 additions and 31 deletions

24
conf.py
View file

@ -27,8 +27,6 @@ import shlex
# ones. # ones.
extensions = [ extensions = [
'sphinx.ext.extlinks', 'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
@ -36,8 +34,7 @@ templates_path = []
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string: # You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md'] source_suffix = ['.rst']
source_suffix = '.rst'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' #source_encoding = 'utf-8-sig'
@ -55,9 +52,9 @@ author = 'PeridexisErrant'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1' version = '0.2'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1' release = '0.2'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
@ -71,10 +68,9 @@ language = None
nitpicky = True nitpicky = True
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used,
#today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y' today_fmt = '%Y-%m-%d'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -127,7 +123,7 @@ html_style = 'dftext.css'
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None html_title = project
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None #html_short_title = None
@ -136,9 +132,7 @@ html_style = 'dftext.css'
# of the sidebar. # of the sidebar.
#html_logo = None #html_logo = None
# The name of an image file (within the static path) to use as favicon of the # The name of an image file (within the static path) to use as the favicon
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = 'misc/df-icon.ico' html_favicon = 'misc/df-icon.ico'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
@ -162,10 +156,10 @@ html_last_updated_fmt = ''
#html_additional_pages = {} #html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True html_domain_indices = False
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True html_use_index = False
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False #html_split_index = False

View file

@ -45,8 +45,7 @@ digging too deep, or learning to make and install mods.
Each tutorial is a short, self-contained introduction to a topic which is Each tutorial is a short, self-contained introduction to a topic which is
likely to be of interest to players who have just finished the walkthrough. likely to be of interest to players who have just finished the walkthrough.
And if you're most interested in somthing not listed here, And if you're most interested in somthing not listed here,
`dwarffortresswiki <http://dwarffortresswiki.org>`_ :wiki:`the wiki <>` and the Bay12 Forums will be your best friends.
and the Bay12 Forums will be your best friends.
.. toctree:: .. toctree::

View file

@ -5,13 +5,13 @@ Any other automatic checks should be in this file too.
""" """
from glob import glob from glob import glob
from io import open import io
import os import os
from os.path import * from os.path import basename, dirname, join, relpath
import sys import sys
text_extensions = ('rst', 'md', 'txt', 'html', 'css', 'js') text_extensions = ('rst', 'md', 'txt', 'html', 'css', 'js')
dirs = ['chapters', 'tutorials', 'masterclass'] DIRS = ['chapters', 'tutorials', 'masterclass']
def error(fname, lineno, issue): def error(fname, lineno, issue):
@ -29,7 +29,7 @@ def lint(path):
if '_build' in fname or not any( if '_build' in fname or not any(
fname.endswith(ext) for ext in text_extensions): fname.endswith(ext) for ext in text_extensions):
continue continue
with open(fname, encoding='utf-8') as fh: with io.open(fname, encoding='utf-8') as fh:
for i, line in enumerate(fh.readlines()): for i, line in enumerate(fh.readlines()):
if len(line) > 81: if len(line) > 81:
failed = True failed = True
@ -49,20 +49,19 @@ def unused_images(path):
"""Check that all files in image subdirs are references in the text.""" """Check that all files in image subdirs are references in the text."""
print('Checking for unused images...') print('Checking for unused images...')
failed = False failed = False
for d in dirs: for d in DIRS:
text = '' text = ''
for fname in glob(os.path.join(d, '*.rst')): for fname in glob(join(d, '*.rst')):
with open(fname, encoding='utf-8') as f: with io.open(fname, encoding='utf-8') as f:
text += f.read() text += f.read()
for img in glob(os.path.join(d, 'images', '*.*')): for img in glob(join(d, 'images', '*.*')):
img = os.path.basename(img) img = basename(img)
if img == 'Thumbs.db': if img == 'Thumbs.db':
continue continue
markup = '.. image:: images/{}'.format(img) markup = '.. image:: images/{}'.format(img)
if markup not in text: if markup not in text:
failed = True failed = True
print('Error: image not referenced, {}/{}/{}'.format( print('Error: not referenced: "{}/images/{}"'.format(d, img))
d, 'images', img))
if failed: if failed:
print('Use or or delete these images.') print('Use or or delete these images.')
return failed return failed
@ -71,6 +70,7 @@ def unused_images(path):
if __name__ == '__main__': if __name__ == '__main__':
# lint everything in the parent directory, wherever the script is run from. # lint everything in the parent directory, wherever the script is run from.
p = relpath(join(dirname(__file__), '..')) p = relpath(join(dirname(__file__), '..'))
failed = lint(p) fail_lint = lint(p)
failed |= unused_images(p) fail_imgs = unused_images(p)
sys.exit(failed) print('lint.py done.')
sys.exit(fail_lint or fail_imgs)