YETUS-415 shelldocs ability to ignore a file

Signed-off-by: Kengo Seki <sekikn@apache.org>
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 @@
   --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.
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 @@
         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 @@
     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: