Print this page
manpage lint.

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/onbld/hgext/cdm.py
          +++ new/usr/src/tools/onbld/hgext/cdm.py
↓ open down ↓ 8 lines elided ↑ open up ↑
   9    9  #  GNU General Public License for more details.
  10   10  #
  11   11  #  You should have received a copy of the GNU General Public License
  12   12  #  along with this program; if not, write to the Free Software
  13   13  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14   14  #
  15   15  
  16   16  #
  17   17  # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  18   18  # Copyright 2008, 2011 Richard Lowe
       19 +# Copyright 2014 Garrett D'Amore <garrett@damore.org>
  19   20  #
  20   21  
  21   22  '''OpenSolaris extensions to Mercurial
  22   23  
  23   24      This extension contains a number of commands to help you work with
  24   25  the OpenSolaris consolidations.  It provides commands to check your
  25   26  changes against the various style rules used for OpenSolaris, to
  26   27  backup and restore your changes, to generate code reviews, and to
  27   28  prepare your changes for integration.
  28   29  
↓ open down ↓ 68 lines elided ↑ open up ↑
  97   98  try:
  98   99      Version.check_version()
  99  100  except Version.VersionMismatch, badversion:
 100  101      raise util.Abort("Version Mismatch:\n %s\n" % badversion)
 101  102  
 102  103  from mercurial import cmdutil, ignore, node, patch
 103  104  
 104  105  from onbld.Scm.WorkSpace import WorkSpace, WorkList
 105  106  from onbld.Scm.Backup import CdmBackup
 106  107  from onbld.Checks import Cddl, Comments, Copyright, CStyle, HdrChk
 107      -from onbld.Checks import JStyle, Keywords, Mapfile
      108 +from onbld.Checks import JStyle, Keywords, ManLint, Mapfile
 108  109  
 109  110  
 110  111  def yes_no(ui, msg, default):
 111  112      if default:
 112  113          prompt = ' [Y/n]:'
 113  114          defanswer = 'y'
 114  115      else:
 115  116          prompt = ' [y/N]:'
 116  117          defanswer = 'n'
 117  118  
↓ open down ↓ 265 lines elided ↑ open up ↑
 383  384              lenient = False
 384  385          else:
 385  386              lenient = True
 386  387  
 387  388          fh = open(f, 'r')
 388  389          ret |= Cddl.cddlchk(fh, lenient=lenient, output=ui)
 389  390          fh.close()
 390  391      return ret
 391  392  
 392  393  
      394 +def cdm_manlintchk(ui, repo, *args, **opts):
      395 +    '''check for mandoc lint
      396 +
      397 +    Check for man page formatting errors.
      398 +
      399 +    Files can be excluded from this check using the manlint.NOT
      400 +    file.  See NOT Files in the extension documentation ('hg help
      401 +    cdm').
      402 +    '''
      403 +
      404 +    filelist = buildfilelist(wslist[repo], opts.get('parent'), args)
      405 +    exclude = not_check(repo, 'manlint')
      406 +    ret = 0
      407 +
      408 +    # Man pages are identified as having a suffix starting with a digit.
      409 +    ManfileRE = re.compile(r'.*\.[0-9][a-z]*$', re.IGNORECASE)
      410 +
      411 +    ui.write('Man format check:\n')
      412 +
      413 +    for f, e in filelist:
      414 +        if e and e.is_removed():
      415 +            continue
      416 +        elif (not ManfileRE.match(f)):
      417 +            continue
      418 +        elif (e or opts.get('honour_nots')) and exclude(f):
      419 +            ui.status('Skipping %s...\n' % f)
      420 +            continue
      421 +
      422 +        fh = open(f, 'r')
      423 +        ret |= ManLint.manlint(fh, output=ui, picky=True)
      424 +        fh.close()
      425 +    return ret
      426 +
      427 +
 393  428  def cdm_mapfilechk(ui, repo, *args, **opts):
 394  429      '''check for a valid mapfile header block in active files
 395  430  
 396  431      Check that all link-editor mapfiles contain the standard mapfile
 397  432      header comment directing the reader to the document containing
 398  433      Solaris object versioning rules (README.mapfile).
 399  434  
 400  435      Files can be excluded from this check using the mapfilechk.NOT
 401  436      file.  See NOT Files in the extension documentation ('hg help
 402  437      cdm').
↓ open down ↓ 384 lines elided ↑ open up ↑
 787  822  
 788  823      Check each active file for basic stylistic errors.
 789  824  
 790  825      The following checks are run over each active file (see 'hg help
 791  826      <check>' for more information about each):
 792  827  
 793  828        - copyright  (copyright statements)
 794  829        - cstyle     (C source style)
 795  830        - hdrchk     (C header style)
 796  831        - jstyle     (java source style)
      832 +      - manlint    (man page formatting)
 797  833        - mapfilechk (link-editor mapfiles)
 798  834        - permchk    (file permissions)
 799  835        - keywords   (SCCS keywords)
 800  836  
 801  837      With the global -q/--quiet option, only provide output for those
 802  838      checks which fail.
 803  839      '''
 804  840  
 805  841      cmds = [cdm_copyright,
 806  842          cdm_cstyle,
 807  843          cdm_hdrchk,
 808  844          cdm_jstyle,
      845 +        cmd_manlintchk,
 809  846          cdm_mapfilechk,
 810  847          cdm_permchk,
 811  848          cdm_keywords]
 812  849  
 813  850      return run_checks(wslist[repo], cmds, *args, **opts)
 814  851  
 815  852  
 816  853  def cdm_pbchk(ui, repo, **opts):
 817  854      '''run pre-integration checks on this workspace
 818  855  
↓ open down ↓ 2 lines elided ↑ open up ↑
 821  858      The following checks are run over the active list (see 'hg help
 822  859      <check>' for more information about each):
 823  860  
 824  861        - branchchk  (addition/modification of branches)
 825  862        - comchk     (changeset descriptions)
 826  863        - copyright  (copyright statements)
 827  864        - cstyle     (C source style)
 828  865        - hdrchk     (C header style)
 829  866        - jstyle     (java source style)
 830  867        - keywords   (SCCS keywords)
      868 +      - manlint    (man page formatting)
 831  869        - mapfilechk (link-editor mapfiles)
 832  870        - permchk    (file permissions)
 833  871        - tagchk     (addition/modification of tags)
 834  872  
 835  873      Additionally, the workspace is checked for outgoing merges (which
 836  874      should be removed with 'hg recommit'), and uncommitted changes.
 837  875  
 838  876      With the global -q/--quiet option, only provide output for those
 839  877      checks which fail.
 840  878      '''
 841  879  
 842  880      #
 843  881      # The current ordering of these is that the commands from cdm_nits
 844  882      # run first in the same order as they would in cdm_nits, then the
 845  883      # pbchk specifics are run.
 846  884      #
 847  885      cmds = [cdm_copyright,
 848  886          cdm_cstyle,
 849  887          cdm_hdrchk,
 850  888          cdm_jstyle,
      889 +        cdm_manlintchk,
 851  890          cdm_mapfilechk,
 852  891          cdm_permchk,
 853  892          cdm_keywords,
 854  893          cdm_comchk,
 855  894          cdm_tagchk,
 856  895          cdm_branchchk,
 857  896          cdm_outchk,
 858  897          cdm_mergechk]
 859  898  
 860  899      return run_checks(wslist[repo], cmds, **opts)
↓ open down ↓ 563 lines elided ↑ open up ↑
1424 1463                 'hg hdrchk [-p PARENT]'),
1425 1464      'jstyle': (cdm_jstyle, [('p', 'parent', '', 'parent workspace')],
1426 1465                 'hg jstyle [-p PARENT]'),
1427 1466      'keywords': (cdm_keywords, [('p', 'parent', '', 'parent workspace')],
1428 1467                   'hg keywords [-p PARENT]'),
1429 1468      '^list|active': (cdm_list, [('p', 'parent', '', 'parent workspace'),
1430 1469                                  ('a', 'added', None, 'show added files'),
1431 1470                                  ('m', 'modified', None, 'show modified files'),
1432 1471                                  ('r', 'removed', None, 'show removed files')],
1433 1472                      'hg list [-amrRu] [-p PARENT]'),
     1473 +    'manlint': (cdm_manlintchk, [('p', 'parent', '', 'parent workspace')],
     1474 +                'hg manlint [-p PARENT]'),
1434 1475      'mapfilechk': (cdm_mapfilechk, [('p', 'parent', '', 'parent workspace')],
1435 1476                  'hg mapfilechk [-p PARENT]'),
1436 1477      '^nits': (cdm_nits, [('p', 'parent', '', 'parent workspace')],
1437 1478               'hg nits [-p PARENT]'),
1438 1479      '^pbchk': (cdm_pbchk, [('p', 'parent', '', 'parent workspace'),
1439 1480                             ('N', 'nocheck', None, 'skip database checks')],
1440 1481                'hg pbchk [-N] [-p PARENT]'),
1441 1482      'permchk': (cdm_permchk, [('p', 'parent', '', 'parent workspace')],
1442 1483                  'hg permchk [-p PARENT]'),
1443 1484      '^pdiffs': (cdm_pdiffs, [('p', 'parent', '', 'parent workspace'),
↓ open down ↓ 44 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX