about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2018-03-05 20:24:05 -0500
committerCorey Farwell <coreyf@rwell.org>2018-03-05 20:27:02 -0500
commit2ec47e07ee933f9497185fc111b3501b8648aef5 (patch)
treee5cea598c0b15c999e90e9ca061b170fd3f507ca
parentc9334404f06a188854af33835a0efe1e834e4ac4 (diff)
downloadrust-2ec47e07ee933f9497185fc111b3501b8648aef5.tar.gz
rust-2ec47e07ee933f9497185fc111b3501b8648aef5.zip
Remove seemingly unused sugarise-doc-comments Python script.
This Python script converts documentation comments from the
`#[doc = "..."]` attribute to the `///` syntax. It was added six
years ago, presumably to help with the transition when `///` was
implemented and hasn't really been touched since. I don't think there's
much value in keeping it around at this point.
-rwxr-xr-xsrc/etc/sugarise-doc-comments.py93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py
deleted file mode 100755
index ac2223f4ace..00000000000
--- a/src/etc/sugarise-doc-comments.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-#
-# this script attempts to turn doc comment attributes (#[doc = "..."])
-# into sugared-doc-comments (/** ... */ and /// ...)
-#
-# it sugarises all .rs/.rc files underneath the working directory
-#
-
-import sys
-import os
-import fnmatch
-import re
-
-
-DOC_PATTERN = '^(?P<indent>[\\t ]*)#\\[(\\s*)doc(\\s*)=' + \
-              '(\\s*)"(?P<text>(\\"|[^"])*?)"(\\s*)\\]' + \
-              '(?P<semi>;)?'
-
-ESCAPES = [("\\'", "'"),
-           ('\\"', '"'),
-           ("\\n", "\n"),
-           ("\\r", "\r"),
-           ("\\t", "\t")]
-
-
-def unescape(s):
-    for (find, repl) in ESCAPES:
-        s = s.replace(find, repl)
-    return s
-
-
-def block_trim(s):
-    lns = s.splitlines()
-
-    # remove leading/trailing whitespace-lines
-    while lns and not lns[0].strip():
-        lns = lns[1:]
-    while lns and not lns[-1].strip():
-        lns = lns[:-1]
-
-    # remove leading horizontal whitespace
-    n = sys.maxsize
-    for ln in lns:
-        if ln.strip():
-            n = min(n, len(re.search('^\s*', ln).group()))
-    if n != sys.maxsize:
-        lns = [ln[n:] for ln in lns]
-
-    # strip trailing whitespace
-    lns = [ln.rstrip() for ln in lns]
-
-    return lns
-
-
-def replace_doc(m):
-    indent = m.group('indent')
-    text = block_trim(unescape(m.group('text')))
-
-    if len(text) > 1:
-        inner = '!' if m.group('semi') else '*'
-        starify = lambda s: indent + ' *' + (' ' + s if s else '')
-        text = '\n'.join(map(starify, text))
-        repl = indent + '/*' + inner + '\n' + text + '\n' + indent + ' */'
-    else:
-        inner = '!' if m.group('semi') else '/'
-        repl = indent + '//' + inner + ' ' + text[0]
-
-    return repl
-
-
-def sugarise_file(path):
-    s = open(path).read()
-
-    r = re.compile(DOC_PATTERN, re.MULTILINE | re.DOTALL)
-    ns = re.sub(r, replace_doc, s)
-
-    if s != ns:
-        open(path, 'w').write(ns)
-
-for (dirpath, dirnames, filenames) in os.walk('.'):
-    for name in fnmatch.filter(filenames, '*.r[sc]'):
-        sugarise_file(os.path.join(dirpath, name))