Repository: yetus Updated Branches: refs/heads/master 54de2af97 -> adeefcaaa
YETUS-415 shelldocs ability to ignore a file Signed-off-by: Kengo Seki <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/adeefcaa Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/adeefcaa Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/adeefcaa Branch: refs/heads/master Commit: adeefcaaad1211ed1c95adfc75f5eef1804609ce Parents: 54de2af Author: Ajay Yadava <[email protected]> Authored: Sun Jul 17 12:54:25 2016 +0530 Committer: Kengo Seki <[email protected]> Committed: Sun Jul 31 15:53:52 2016 +0000 ---------------------------------------------------------------------- .../source/documentation/in-progress.html.md | 2 ++ shelldocs/shelldocs.py | 31 +++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/adeefcaa/asf-site-src/source/documentation/in-progress.html.md ---------------------------------------------------------------------- diff --git a/asf-site-src/source/documentation/in-progress.html.md b/asf-site-src/source/documentation/in-progress.html.md index a23136b..15f44d8 100644 --- a/asf-site-src/source/documentation/in-progress.html.md +++ b/asf-site-src/source/documentation/in-progress.html.md @@ -53,6 +53,8 @@ Options: --skipprnorep Skip Private & Not Replaceable ``` +You can mark a file to be ignored by shelldocs by adding "SHELLDOC-IGNORE" as a comment in its own line. + # Yetus Audience Annotations Audience Annotations allows you to use Java Annotations to denote which parts of your Java library is publicly consumable and which parts are reserved for a more restricted use. It also provides doclets and examples for generating javadocs limited by audience. http://git-wip-us.apache.org/repos/asf/yetus/blob/adeefcaa/shelldocs/shelldocs.py ---------------------------------------------------------------------- diff --git a/shelldocs/shelldocs.py b/shelldocs/shelldocs.py index 70d486c..cc206db 100755 --- a/shelldocs/shelldocs.py +++ b/shelldocs/shelldocs.py @@ -290,11 +290,36 @@ class ShellFunction(object): return line +def marked_as_ignored(file_path): + """Checks for the presence of the marker(SHELLDOC-IGNORE) to ignore the file. + + Marker needs to be in a line of its own and can not + be an inline comment. + + A leading '#' and white-spaces(leading or trailing) + are trimmed before checking equality. + + Comparison is case sensitive and the comment must be in + UPPERCASE. + """ + with open(file_path) as input_file: + for line_num, line in enumerate(input_file, 1): + if line.startswith("#") and line[1:].strip() == "SHELLDOC-IGNORE": + print >> sys.stderr, "Yo! Got an ignore directive in",\ + "file:{} on line number:{}".format(file_path, line_num) + return True + return False + + def main(): '''main entry point''' parser = OptionParser( usage="usage: %prog [--skipprnorep] " + "[--output OUTFILE|--lint] " + - "--input INFILE " + "[--input INFILE ...]") + "--input INFILE " + "[--input INFILE ...]", + epilog= + "You can mark a file to be ignored by shelldocs by adding" + " 'SHELLDOC-IGNORE' as comment in its own line." + ) parser.add_option("-o", "--output", dest="outfile", @@ -344,6 +369,10 @@ def main(): try: for filename in options.infile: with open(filename, "r") as shellcode: + # if the file contains a comment containing + # only "SHELLDOC-IGNORE" then skip that file + if marked_as_ignored(filename): + continue funcdef = ShellFunction(filename) linenum = 0 for line in shellcode:
