Print this page
manpage lint.

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/git-pbchk.py
          +++ new/usr/src/tools/scripts/git-pbchk.py
↓ open down ↓ 9 lines elided ↑ open up ↑
  10   10  #  GNU General Public License for more details.
  11   11  #
  12   12  #  You should have received a copy of the GNU General Public License
  13   13  #  along with this program; if not, write to the Free Software
  14   14  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15   15  #
  16   16  
  17   17  #
  18   18  # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  19   19  # Copyright 2008, 2012 Richard Lowe
       20 +# Copyright 2014 Garrett D'Amore <garrett@damore.org>
  20   21  #
  21   22  
  22   23  import getopt
  23   24  import os
  24   25  import re
  25   26  import subprocess
  26   27  import sys
  27   28  import tempfile
  28   29  
  29   30  from cStringIO import StringIO
↓ open down ↓ 11 lines elided ↑ open up ↑
  41   42  sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
  42   43                                  "python%d.%d" % sys.version_info[:2]))
  43   44  
  44   45  #
  45   46  # Add the relative path to usr/src/tools to the load path, such that when run
  46   47  # from the source tree we use the modules also within the source tree.
  47   48  #
  48   49  sys.path.insert(2, os.path.join(os.path.dirname(__file__), ".."))
  49   50  
  50   51  from onbld.Checks import Comments, Copyright, CStyle, HdrChk
  51      -from onbld.Checks import JStyle, Keywords, Mapfile
       52 +from onbld.Checks import JStyle, Keywords, ManLint, Mapfile
  52   53  
  53   54  
  54   55  class GitError(Exception):
  55   56      pass
  56   57  
  57   58  def git(command):
  58   59      """Run a command and return a stream containing its stdout (and write its
  59   60      stderr to its stdout)"""
  60   61  
  61   62      if type(command) != list:
↓ open down ↓ 213 lines elided ↑ open up ↑
 275  276  def jstyle(root, parent, flist, output):
 276  277      ret = 0
 277  278      output.write("Java style:\n")
 278  279      for f in flist(lambda x: x.endswith('.java')):
 279  280          fh = open(f, 'r')
 280  281          ret |= JStyle.jstyle(fh, output=output, picky=True)
 281  282          fh.close()
 282  283      return ret
 283  284  
 284  285  
      286 +def manlint(root, parent, flist, output):
      287 +    ret = 0
      288 +    output.write("Man page format:\n")
      289 +    ManfileRE = re.compile(r'.*\.[0-9][a-z]*$', re.IGNORECASE)
      290 +    for f in flist(lambda x: ManfileRE.match(x)):
      291 +        fh = open(f, 'r')
      292 +        ret |= ManLint.manlint(fh, output=output, picky=True)
      293 +        fh.close()
      294 +    return ret
      295 +
 285  296  def keywords(root, parent, flist, output):
 286  297      ret = 0
 287  298      output.write("SCCS Keywords:\n")
 288  299      for f in flist():
 289  300          fh = open(f, 'r')
 290  301          ret |= Keywords.keywords(fh, output=output)
 291  302          fh.close()
 292  303      return ret
 293  304  
 294  305  
↓ open down ↓ 21 lines elided ↑ open up ↑
 316  327  
 317  328      return ret
 318  329  
 319  330  
 320  331  def nits(root, parent, paths):
 321  332      cmds = [copyright,
 322  333              cstyle,
 323  334              hdrchk,
 324  335              jstyle,
 325  336              keywords,
      337 +            manlint,
 326  338              mapfilechk]
 327  339      run_checks(root, parent, cmds, paths)
 328  340  
 329  341  
 330  342  def pbchk(root, parent, paths):
 331  343      cmds = [comchk,
 332  344              copyright,
 333  345              cstyle,
 334  346              hdrchk,
 335  347              jstyle,
 336  348              keywords,
      349 +            manlint,
 337  350              mapfilechk]
 338  351      run_checks(root, parent, cmds)
 339  352  
 340  353  
 341  354  def main(cmd, args):
 342  355      parent_branch = None
 343  356  
 344  357      try:
 345  358          opts, args = getopt.getopt(args, 'b:')
 346  359      except getopt.GetoptError, e:
↓ open down ↓ 26 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX