1*95c635efSGarrett D'Amore# 2*95c635efSGarrett D'Amore# CDDL HEADER START 3*95c635efSGarrett D'Amore# 4*95c635efSGarrett D'Amore# The contents of this file are subject to the terms of the 5*95c635efSGarrett D'Amore# Common Development and Distribution License (the "License"). 6*95c635efSGarrett D'Amore# You may not use this file except in compliance with the License. 7*95c635efSGarrett D'Amore# 8*95c635efSGarrett D'Amore# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*95c635efSGarrett D'Amore# or http://www.opensolaris.org/os/licensing. 10*95c635efSGarrett D'Amore# See the License for the specific language governing permissions 11*95c635efSGarrett D'Amore# and limitations under the License. 12*95c635efSGarrett D'Amore# 13*95c635efSGarrett D'Amore# When distributing Covered Code, include this CDDL HEADER in each 14*95c635efSGarrett D'Amore# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*95c635efSGarrett D'Amore# If applicable, add the following below this CDDL HEADER, with the 16*95c635efSGarrett D'Amore# fields enclosed by brackets "[]" replaced with your own identifying 17*95c635efSGarrett D'Amore# information: Portions Copyright [yyyy] [name of copyright owner] 18*95c635efSGarrett D'Amore# 19*95c635efSGarrett D'Amore# CDDL HEADER END 20*95c635efSGarrett D'Amore# 21*95c635efSGarrett D'Amore 22*95c635efSGarrett D'Amore# 23*95c635efSGarrett D'Amore# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*95c635efSGarrett D'Amore# Use is subject to license terms. 25*95c635efSGarrett D'Amore# 26*95c635efSGarrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org> 27*95c635efSGarrett D'Amore# 28*95c635efSGarrett D'Amore 29*95c635efSGarrett D'Amore# 30*95c635efSGarrett D'Amore# ManLint, wrap the mandoc lint tool in a pythonic API 31*95c635efSGarrett D'Amore# 32*95c635efSGarrett D'Amore 33*95c635efSGarrett D'Amoreimport sys 34*95c635efSGarrett D'Amorefrom onbld.Checks.ProcessCheck import processcheck 35*95c635efSGarrett D'Amore 36*95c635efSGarrett D'Amoredef manlint(fh, filename=None, output=sys.stderr, **opts): 37*95c635efSGarrett D'Amore opttrans = { 'picky': None } 38*95c635efSGarrett D'Amore 39*95c635efSGarrett D'Amore for x in filter(lambda x: x not in opttrans, opts): 40*95c635efSGarrett D'Amore raise TypeError('mandoc() got an unexpected keyword ' 41*95c635efSGarrett D'Amore 'argument %s' % x) 42*95c635efSGarrett D'Amore 43*95c635efSGarrett D'Amore options = [opttrans[x] for x in opts if opts[x] and opttrans[x]] 44*95c635efSGarrett D'Amore options.append('-Tlint') 45*95c635efSGarrett D'Amore 46*95c635efSGarrett D'Amore if not filename: 47*95c635efSGarrett D'Amore filename = fh.name 48*95c635efSGarrett D'Amore 49*95c635efSGarrett D'Amore ret, tmpfile = processcheck('mandoc', options, fh, output) 50*95c635efSGarrett D'Amore 51*95c635efSGarrett D'Amore if tmpfile: 52*95c635efSGarrett D'Amore for line in tmpfile: 53*95c635efSGarrett D'Amore line = line.replace('<stdin>', filename) 54*95c635efSGarrett D'Amore output.write(line) 55*95c635efSGarrett D'Amore 56*95c635efSGarrett D'Amore tmpfile.close() 57*95c635efSGarrett D'Amore return ret 58