Browse Source

Removes unused sphinx extensions

Ask Solem 9 years ago
parent
commit
fb73772104
2 changed files with 0 additions and 271 deletions
  1. 0 91
      docs/_ext/applyxrefs.py
  2. 0 180
      docs/_ext/literals_to_xrefs.py

+ 0 - 91
docs/_ext/applyxrefs.py

@@ -1,91 +0,0 @@
-"""Adds xref targets to the top of files."""
-from __future__ import absolute_import, unicode_literals
-
-import sys
-import os
-
-testing = False
-
-DONT_TOUCH = (
-    './index.txt',
-)
-
-
-def target_name(fn):
-    if fn.endswith('.txt'):
-        fn = fn[:-4]
-    return '_' + fn.lstrip('./').replace('/', '-')
-
-
-def process_file(fn, lines):
-    lines.insert(0, '\n')
-    lines.insert(0, '.. %s:\n' % target_name(fn))
-    try:
-        f = open(fn, 'w')
-    except IOError:
-        print("Can't open %s for writing. Not touching it." % fn)
-        return
-    try:
-        f.writelines(lines)
-    except IOError:
-        print("Can't write to %s. Not touching it." % fn)
-    finally:
-        f.close()
-
-
-def has_target(fn):
-    try:
-        f = open(fn, 'r')
-    except IOError:
-        print("Can't open %s. Not touching it." % fn)
-        return (True, None)
-    readok = True
-    try:
-        lines = f.readlines()
-    except IOError:
-        print("Can't read %s. Not touching it." % fn)
-        readok = False
-    finally:
-        f.close()
-        if not readok:
-            return (True, None)
-
-    if len(lines) < 1:
-        print('Not touching empty file %s.' % fn)
-        return (True, None)
-    if lines[0].startswith('.. _'):
-        return (True, None)
-    return (False, lines)
-
-
-def main(argv=None):
-    if argv is None:
-        argv = sys.argv
-
-    if len(argv) == 1:
-        argv.extend('.')
-
-    files = []
-    for root in argv[1:]:
-        for (dirpath, dirnames, filenames) in os.walk(root):
-            files.extend([(dirpath, f) for f in filenames])
-    files.sort()
-    files = [os.path.join(p, fn) for p, fn in files if fn.endswith('.txt')]
-
-    for fn in files:
-        if fn in DONT_TOUCH:
-            print('Skipping blacklisted file %s.' % fn)
-            continue
-
-        target_found, lines = has_target(fn)
-        if not target_found:
-            if testing:
-                print '%s: %s' % (fn, lines[0]),
-            else:
-                print 'Adding xref to %s' % fn
-                process_file(fn, lines)
-        else:
-            print 'Skipping %s: already has a xref' % fn
-
-if __name__ == '__main__':
-    sys.exit(main())

+ 0 - 180
docs/_ext/literals_to_xrefs.py

@@ -1,180 +0,0 @@
-"""
-Runs through a reST file looking for old-style literals, and helps replace them
-with new-style references.
-"""
-from __future__ import absolute_import, unicode_literals
-
-import re
-import sys
-import shelve
-
-try:
-    input = input
-except NameError:
-    input = raw_input  # noqa
-
-refre = re.compile(r'``([^`\s]+?)``')
-
-ROLES = (
-    'attr',
-    'class',
-    'djadmin',
-    'data',
-    'exc',
-    'file',
-    'func',
-    'lookup',
-    'meth',
-    'mod',
-    'djadminopt',
-    'ref',
-    'setting',
-    'term',
-    'tfilter',
-    'ttag',
-
-    # special
-    'skip',
-)
-
-ALWAYS_SKIP = [
-    'NULL',
-    'True',
-    'False',
-]
-
-
-def fixliterals(fname):
-    data = open(fname).read()
-
-    last = 0
-    new = []
-    storage = shelve.open('/tmp/literals_to_xref.shelve')
-    lastvalues = storage.get('lastvalues', {})
-
-    for m in refre.finditer(data):
-
-        new.append(data[last:m.start()])
-        last = m.end()
-
-        line_start = data.rfind('\n', 0, m.start())
-        line_end = data.find('\n', m.end())
-        prev_start = data.rfind('\n', 0, line_start)
-        next_end = data.find('\n', line_end + 1)
-
-        # Skip always-skip stuff
-        if m.group(1) in ALWAYS_SKIP:
-            new.append(m.group(0))
-            continue
-
-        # skip when the next line is a title
-        next_line = data[m.end():next_end].strip()
-        if next_line[0] in '!-/:-@[-`{-~' and \
-                all(c == next_line[0] for c in next_line):
-            new.append(m.group(0))
-            continue
-
-        sys.stdout.write('\n' + '-' * 80 + '\n')
-        sys.stdout.write(data[prev_start + 1:m.start()])
-        sys.stdout.write(colorize(m.group(0), fg='red'))
-        sys.stdout.write(data[m.end():next_end])
-        sys.stdout.write('\n\n')
-
-        replace_type = None
-        while replace_type is None:
-            replace_type = input(
-                colorize('Replace role: ', fg='yellow')).strip().lower()
-            if replace_type and replace_type not in ROLES:
-                replace_type = None
-
-        if replace_type == '':
-            new.append(m.group(0))
-            continue
-
-        if replace_type == 'skip':
-            new.append(m.group(0))
-            ALWAYS_SKIP.append(m.group(1))
-            continue
-
-        default = lastvalues.get(m.group(1), m.group(1))
-        if default.endswith('()') and \
-                replace_type in ('class', 'func', 'meth'):
-            default = default[:-2]
-        replace_value = input(
-            colorize('Text <target> [', fg='yellow') +
-            default + colorize(']: ', fg='yellow'),
-        ).strip()
-        if not replace_value:
-            replace_value = default
-        new.append(':%s:`%s`' % (replace_type, replace_value))
-        lastvalues[m.group(1)] = replace_value
-
-    new.append(data[last:])
-    open(fname, 'w').write(''.join(new))
-
-    storage['lastvalues'] = lastvalues
-    storage.close()
-
-
-def colorize(text='', opts=(), **kwargs):
-    """
-    Returns your text, enclosed in ANSI graphics codes.
-
-    Depends on the keyword arguments 'fg' and 'bg', and the contents of
-    the opts tuple/list.
-
-    Returns the RESET code if no parameters are given.
-
-    Valid colors:
-        'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
-
-    Valid options:
-        'bold'
-        'underscore'
-        'blink'
-        'reverse'
-        'conceal'
-        'noreset' - string will not be auto-terminated with the RESET code
-
-    Examples:
-        colorize('hello', fg='red', bg='blue', opts=('blink',))
-        colorize()
-        colorize('goodbye', opts=('underscore',))
-        print colorize('first line', fg='red', opts=('noreset',))
-        print 'this should be red too'
-        print colorize('and so should this')
-        print 'this should not be red'
-    """
-    color_names = ('black', 'red', 'green', 'yellow',
-                   'blue', 'magenta', 'cyan', 'white')
-    foreground = {color_names[x]: '3%s' % x for x in range(8)}
-    background = {color_names[x]: '4%s' % x for x in range(8)}
-
-    RESET = '0'
-    opt_dict = {'bold': '1',
-                'underscore': '4',
-                'blink': '5',
-                'reverse': '7',
-                'conceal': '8'}
-
-    text = str(text)
-    code_list = []
-    if text == '' and len(opts) == 1 and opts[0] == 'reset':
-        return '\x1b[%sm' % RESET
-    for k, v in kwargs.items():
-        if k == 'fg':
-            code_list.append(foreground[v])
-        elif k == 'bg':
-            code_list.append(background[v])
-    for o in opts:
-        if o in opt_dict:
-            code_list.append(opt_dict[o])
-    if 'noreset' not in opts:
-        text = text + '\x1b[%sm' % RESET
-    return ('\x1b[%sm' % ';'.join(code_list)) + text
-
-if __name__ == '__main__':
-    try:
-        fixliterals(sys.argv[1])
-    except (KeyboardInterrupt, SystemExit):
-        print