YETUS-289. shelldocs should output error positions in lint mode Signed-off-by: Sean Busbey <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/585e97d4 Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/585e97d4 Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/585e97d4 Branch: refs/heads/YETUS-379 Commit: 585e97d45a86991e23b83ea32216d4b4b50fac60 Parents: 9f0f3d8 Author: Allen Wittenauer <[email protected]> Authored: Thu Apr 14 10:08:16 2016 -0700 Committer: Allen Wittenauer <[email protected]> Committed: Sun Apr 17 10:08:15 2016 -0700 ---------------------------------------------------------------------- precommit/personality/accumulo.sh | 8 ++++++ precommit/personality/bigtop.sh | 43 +++-------------------------- precommit/personality/drill.sh | 3 +++ precommit/personality/flink.sh | 3 +++ precommit/personality/geode.sh | 3 +++ precommit/personality/hadoop.sh | 27 +++++++++++++++++++ precommit/personality/hbase.sh | 8 ++++++ precommit/personality/jmeter.sh | 10 +++++++ precommit/personality/kafka.sh | 8 ++++++ precommit/personality/orc.sh | 3 +++ precommit/personality/pig.sh | 8 ++++++ precommit/personality/samza.sh | 4 ++- precommit/personality/tajo.sh | 3 +++ precommit/personality/tez.sh | 3 +++ shelldocs/shelldocs.py | 49 +++++++++++++++++++++++++--------- 15 files changed, 130 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/accumulo.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/accumulo.sh b/precommit/personality/accumulo.sh index de1b890..d99bf82 100755 --- a/precommit/personality/accumulo.sh +++ b/precommit/personality/accumulo.sh @@ -17,6 +17,9 @@ # Run all plugins personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 @@ -33,6 +36,11 @@ function personality_globals CHECKSTYLE_GOAL="check" } +## @description Queue up modules for this personality +## @audience private +## @stability evolving +## @param repostatus +## @param testtype function personality_modules { local repostatus=$1 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/bigtop.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/bigtop.sh b/precommit/personality/bigtop.sh index 039618b..c374289 100755 --- a/precommit/personality/bigtop.sh +++ b/precommit/personality/bigtop.sh @@ -16,6 +16,9 @@ personality_plugins "all,-checkstyle,-findbugs" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { # shellcheck disable=SC2034 @@ -26,44 +29,4 @@ function personality_globals BUILDTOOL=gradle # shellcheck disable=SC2034 GITHUB_REPO="apache/bigtop" - # shellcheck disable=SC2034 - BIGTOP_PUPPETSETUP=false -} - -add_test_type bigtop - -function bigtop_usage -{ - yetus_add_option "--bigtop-puppet=[false|true]" "execute the bigtop puppet setup (needs sudo to root)" -} - -function bigtop_parse_args -{ - local i - - for i in "$@"; do - case ${i} in - --bigtop-puppet=*) - BIGTOP_PUPPETSETUP=${i#*=} - ;; - esac - done -} - -function bigtop_precheck_postinstall -{ - if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then - pushd "${BASEDIR}" >/dev/null - echo_and_redirect "${PATCH_DIR}/bigtop-branch-toolchain.txt" "${GRADLEW}" toolchain - popd >/dev/null - fi -} - -function bigtop_postapply_postinstall -{ - if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then - pushd "${BASEDIR}" >/dev/null - echo_and_redirect "${PATCH_DIR}/bigtop-patch-toolchain.txt" "${GRADLEW}" toolchain - popd >/dev/null - fi } http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/drill.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/drill.sh b/precommit/personality/drill.sh index 48fcb2e..b58ed07 100755 --- a/precommit/personality/drill.sh +++ b/precommit/personality/drill.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/flink.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/flink.sh b/precommit/personality/flink.sh index 8a077ac..6b4f0a8 100755 --- a/precommit/personality/flink.sh +++ b/precommit/personality/flink.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/geode.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/geode.sh b/precommit/personality/geode.sh index f345fe8..9f5c0ec 100755 --- a/precommit/personality/geode.sh +++ b/precommit/personality/geode.sh @@ -16,6 +16,9 @@ personality_plugins "all,-ant,-javac,-scalac,-scaladoc" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/hadoop.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/hadoop.sh b/precommit/personality/hadoop.sh index 02df4b1..59dfd2c 100755 --- a/precommit/personality/hadoop.sh +++ b/precommit/personality/hadoop.sh @@ -18,6 +18,9 @@ personality_plugins "all,-ant,-gradle,-scalac,-scaladoc" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 @@ -32,6 +35,10 @@ function personality_globals PYLINT_OPTIONS="--indent-string=' '" } +## @description Calculate the actual module ordering +## @audience private +## @stability evolving +## @param ordering function hadoop_order { declare ordering=$1 @@ -47,6 +54,10 @@ function hadoop_order echo "${hadoopm}" } +## @description Install extra modules for unit tests +## @audience private +## @stability evolving +## @param ordering function hadoop_unittest_prereqs { declare input=$1 @@ -88,6 +99,10 @@ function hadoop_unittest_prereqs fi } +## @description Calculate the flags/settings for native code +## @description based upon the OS +## @audience private +## @stability evolving function hadoop_native_flags { @@ -137,6 +152,11 @@ function hadoop_native_flags esac } +## @description Queue up modules for this personality +## @audience private +## @stability evolving +## @param repostatus +## @param testtype function personality_modules { declare repostatus=$1 @@ -269,6 +289,10 @@ function personality_modules done } +## @description Add tests based upon personality needs +## @audience private +## @stability evolving +## @param filename function personality_file_tests { declare filename=$1 @@ -332,6 +356,9 @@ function personality_file_tests fi } +## @description Image to print on success +## @audience private +## @stability evolving function hadoop_console_success { printf "IF9fX19fX19fX18gCjwgU3VjY2VzcyEgPgogLS0tLS0tLS0tLSAKIFwgICAg"; http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/hbase.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/hbase.sh b/precommit/personality/hbase.sh index 7863bb2..352d2e3 100755 --- a/precommit/personality/hbase.sh +++ b/precommit/personality/hbase.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 @@ -32,6 +35,11 @@ function personality_globals MAVEN_OPTS="${MAVEN_OPTS:-"-Xmx3100M"}" } +## @description Queue up modules for this personality +## @audience private +## @stability evolving +## @param repostatus +## @param testtype function personality_modules { local repostatus=$1 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/jmeter.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/jmeter.sh b/precommit/personality/jmeter.sh index a9da710..194fc4f 100755 --- a/precommit/personality/jmeter.sh +++ b/precommit/personality/jmeter.sh @@ -16,6 +16,9 @@ personality_plugins "all,-javadoc,-findbugs,-asflicense" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { # shellcheck disable=SC2034 @@ -30,11 +33,18 @@ function personality_globals add_test_type jmeter +## @description Personality usage options +## @audience private +## @stability evolving function jmeter_usage { yetus_add_option "--jmeter-download-jars=<bool>" "download third-party jars needed by ant build" } +## @description Process personality options +## @audience private +## @stability evolving +## @param arguments function jmeter_parse_args { declare i http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/kafka.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/kafka.sh b/precommit/personality/kafka.sh index 8d866c9..0c2f749 100755 --- a/precommit/personality/kafka.sh +++ b/precommit/personality/kafka.sh @@ -16,6 +16,9 @@ personality_plugins "all,-checkstyle,-asflicense" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 @@ -30,6 +33,11 @@ function personality_globals GITHUB_REPO="apache/kafka" } +## @description Queue up modules for this personality +## @audience private +## @stability evolving +## @param repostatus +## @param testtype function personality_modules { declare repostatus=$1 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/orc.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/orc.sh b/precommit/personality/orc.sh index b4fda31..0582b17 100755 --- a/precommit/personality/orc.sh +++ b/precommit/personality/orc.sh @@ -16,6 +16,9 @@ personality_plugins "all,-checkstyle,-findbugs" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/pig.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/pig.sh b/precommit/personality/pig.sh index 639df01..2014fda 100755 --- a/precommit/personality/pig.sh +++ b/precommit/personality/pig.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 @@ -28,6 +31,11 @@ function personality_globals BUILDTOOL=ant } +## @description Queue up modules for this personality +## @audience private +## @stability evolving +## @param repostatus +## @param testtype function personality_modules { local repostatus=$1 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/samza.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/samza.sh b/precommit/personality/samza.sh index e649106..430ffbb 100755 --- a/precommit/personality/samza.sh +++ b/precommit/personality/samza.sh @@ -14,9 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. - personality_plugins "all,-checkstyle" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/tajo.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/tajo.sh b/precommit/personality/tajo.sh index ffe580a..32b4242 100755 --- a/precommit/personality/tajo.sh +++ b/precommit/personality/tajo.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/precommit/personality/tez.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/tez.sh b/precommit/personality/tez.sh index 91ea0e5..4b0e3ec 100755 --- a/precommit/personality/tez.sh +++ b/precommit/personality/tez.sh @@ -16,6 +16,9 @@ personality_plugins "all" +## @description Globals specific to this personality +## @audience private +## @stability evolving function personality_globals { #shellcheck disable=SC2034 http://git-wip-us.apache.org/repos/asf/yetus/blob/585e97d4/shelldocs/shelldocs.py ---------------------------------------------------------------------- diff --git a/shelldocs/shelldocs.py b/shelldocs/shelldocs.py index e575add..70d486c 100755 --- a/shelldocs/shelldocs.py +++ b/shelldocs/shelldocs.py @@ -66,7 +66,8 @@ def toc(tlist): class ShellFunction(object): """a shell function""" - def __init__(self): + + def __init__(self, filename): '''Initializer''' self.name = None self.audience = None @@ -75,6 +76,8 @@ class ShellFunction(object): self.returnt = None self.desc = None self.params = None + self.filename = filename + self.linenum = 0 def __cmp__(self, other): '''comparison''' @@ -102,6 +105,15 @@ class ShellFunction(object): self.returnt = None self.desc = None self.params = None + self.linenum = 0 + self.filename = None + + def getfilename(self): + '''get the name of the function''' + if self.filename is None: + return "undefined" + else: + return self.filename def setname(self, text): '''set the name of the function''' @@ -115,6 +127,14 @@ class ShellFunction(object): else: return self.name + def setlinenum(self, linenum): + '''set the line number of the function''' + self.linenum = linenum + + def getlinenum(self): + '''get the line number of the function''' + return self.linenum + def setaudience(self, text): '''set the audience of the function''' self.audience = docstrip("audience", text) @@ -249,13 +269,15 @@ class ShellFunction(object): for attr in ("audience", "stability", "replaceable"): value = getfuncs[attr]() if value == "None": - messages.append("ERROR: function %s has no @%s" % - (self.getname(), attr.lower())) + messages.append("%s:%u: ERROR: function %s has no @%s" % + (self.getfilename(), self.getlinenum(), + self.getname(), attr.lower())) elif value not in validvalues[attr]: validvalue = "|".join(v.lower() for v in validvalues[attr]) messages.append( - "ERROR: function %s has invalid value (%s) for @%s (%s)" % - (self.getname(), value.lower(), attr.lower(), validvalue)) + "%s:%u: ERROR: function %s has invalid value (%s) for @%s (%s)" + % (self.getfilename(), self.getlinenum(), self.getname(), + value.lower(), attr.lower(), validvalue)) return "\n".join(messages) def __str__(self): @@ -271,8 +293,8 @@ class ShellFunction(object): def main(): '''main entry point''' parser = OptionParser( - usage= - "usage: %prog [--skipprnorep] --output OUTFILE --input INFILE [--input INFILE ...]") + usage="usage: %prog [--skipprnorep] " + "[--output OUTFILE|--lint] " + + "--input INFILE " + "[--input INFILE ...]") parser.add_option("-o", "--output", dest="outfile", @@ -303,12 +325,12 @@ def main(): default=False, help="display version information for shelldocs and exit.") - (options, args) = parser.parse_args() + (options, dummy_args) = parser.parse_args() if options.release_version: with open( - os.path.join( - os.path.dirname(__file__), "../VERSION"), 'r') as ver_file: + os.path.join( + os.path.dirname(__file__), "../VERSION"), 'r') as ver_file: print ver_file.read() sys.exit(0) @@ -322,8 +344,10 @@ def main(): try: for filename in options.infile: with open(filename, "r") as shellcode: - funcdef = ShellFunction() + funcdef = ShellFunction(filename) + linenum = 0 for line in shellcode: + linenum = linenum + 1 if line.startswith('## @description'): funcdef.adddesc(line) elif line.startswith('## @audience'): @@ -338,13 +362,14 @@ def main(): funcdef.addreturn(line) elif line.startswith('function'): funcdef.setname(line) + funcdef.setlinenum(linenum) if options.skipprnorep and \ funcdef.getaudience() == "Private" and \ funcdef.getreplace() == "No": pass else: allfuncs.append(funcdef) - funcdef = ShellFunction() + funcdef = ShellFunction(filename) except IOError, err: print >> sys.stderr, "ERROR: Failed to read from file: %s. Aborting." % err.filename sys.exit(1)
