langtools/test/tools/doclint/tidy/util/tidy.sh
author lana
Tue, 08 Aug 2017 22:52:41 +0000
changeset 46173 5546b5710844
parent 20263 e7ce67bbe293
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20263
e7ce67bbe293 8025412: Add legal header and comments to test/tools/doclint/tidy/util/Main.java
jjg
parents: 14952
diff changeset
     1
#!/bin/bash
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     2
#
20263
e7ce67bbe293 8025412: Add legal header and comments to test/tools/doclint/tidy/util/Main.java
jjg
parents: 14952
diff changeset
     3
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     5
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     8
# published by the Free Software Foundation.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
     9
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    14
# accompanied this code).
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    15
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    19
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    22
# questions.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    23
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    24
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    25
# Run the "tidy" program over the files in a directory.
20263
e7ce67bbe293 8025412: Add legal header and comments to test/tools/doclint/tidy/util/Main.java
jjg
parents: 14952
diff changeset
    26
# The "tidy" program must be on your PATH.
14952
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    27
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    28
# Usage:
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    29
#   sh tidy.sh <dir>
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    30
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    31
# The "tidy" program will be run on each HTML file in <dir>,
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    32
# and the output placed in the corresponding location in a new
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    33
# directory <dir>.tidy.  The console output from running "tidy" will
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    34
# be saved in a corresponding file with an additional .tidy extension.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    35
#
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    36
# Non-HTML files will be copied without modification from <dir> to
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    37
# <dir>.tidy, so that relative links within the directory tree are
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    38
# unaffected.
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    39
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    40
dir=$1
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    41
odir=$dir.tidy
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    42
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    43
( cd $dir ; find . -type f ) | \
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    44
    while read file ; do
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    45
        mkdir -p $odir/$(dirname $file)
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    46
        case $file in
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    47
            *.html )
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    48
                cat $dir/$file | tidy 1>$odir/$file 2>$odir/$file.tidy
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    49
                ;;
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    50
            * ) cp $dir/$file $odir/$file
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    51
                ;;
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    52
        esac
d0022ae20516 8004832: Add new doclint package
jjg
parents:
diff changeset
    53
    done