195c635efSGarrett D'Amore# 295c635efSGarrett D'Amore# CDDL HEADER START 395c635efSGarrett D'Amore# 495c635efSGarrett D'Amore# The contents of this file are subject to the terms of the 595c635efSGarrett D'Amore# Common Development and Distribution License (the "License"). 695c635efSGarrett D'Amore# You may not use this file except in compliance with the License. 795c635efSGarrett D'Amore# 895c635efSGarrett D'Amore# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 995c635efSGarrett D'Amore# or http://www.opensolaris.org/os/licensing. 1095c635efSGarrett D'Amore# See the License for the specific language governing permissions 1195c635efSGarrett D'Amore# and limitations under the License. 1295c635efSGarrett D'Amore# 1395c635efSGarrett D'Amore# When distributing Covered Code, include this CDDL HEADER in each 1495c635efSGarrett D'Amore# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1595c635efSGarrett D'Amore# If applicable, add the following below this CDDL HEADER, with the 1695c635efSGarrett D'Amore# fields enclosed by brackets "[]" replaced with your own identifying 1795c635efSGarrett D'Amore# information: Portions Copyright [yyyy] [name of copyright owner] 1895c635efSGarrett D'Amore# 1995c635efSGarrett D'Amore# CDDL HEADER END 2095c635efSGarrett D'Amore# 2195c635efSGarrett D'Amore 2295c635efSGarrett D'Amore# 2395c635efSGarrett D'Amore# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2495c635efSGarrett D'Amore# Use is subject to license terms. 2595c635efSGarrett D'Amore# 2695c635efSGarrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org> 2795c635efSGarrett D'Amore# 2895c635efSGarrett D'Amore 2995c635efSGarrett D'Amore# 3095c635efSGarrett D'Amore# ManLint, wrap the mandoc lint tool in a pythonic API 3195c635efSGarrett D'Amore# 3295c635efSGarrett D'Amore 3395c635efSGarrett D'Amoreimport sys 3495c635efSGarrett D'Amorefrom onbld.Checks.ProcessCheck import processcheck 3595c635efSGarrett D'Amore 3695c635efSGarrett D'Amoredef manlint(fh, filename=None, output=sys.stderr, **opts): 3795c635efSGarrett D'Amore opttrans = { 'picky': None } 3895c635efSGarrett D'Amore 3995c635efSGarrett D'Amore for x in filter(lambda x: x not in opttrans, opts): 4095c635efSGarrett D'Amore raise TypeError('mandoc() got an unexpected keyword ' 4195c635efSGarrett D'Amore 'argument %s' % x) 4295c635efSGarrett D'Amore 4395c635efSGarrett D'Amore options = [opttrans[x] for x in opts if opts[x] and opttrans[x]] 4495c635efSGarrett D'Amore options.append('-Tlint') 45*c66b8046SYuri Pankov options.append('-Wwarning') 4695c635efSGarrett D'Amore 4795c635efSGarrett D'Amore if not filename: 4895c635efSGarrett D'Amore filename = fh.name 4995c635efSGarrett D'Amore 5095c635efSGarrett D'Amore ret, tmpfile = processcheck('mandoc', options, fh, output) 5195c635efSGarrett D'Amore 5295c635efSGarrett D'Amore if tmpfile: 5395c635efSGarrett D'Amore for line in tmpfile: 5495c635efSGarrett D'Amore line = line.replace('<stdin>', filename) 5595c635efSGarrett D'Amore output.write(line) 5695c635efSGarrett D'Amore 5795c635efSGarrett D'Amore tmpfile.close() 5895c635efSGarrett D'Amore return ret 59