Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
2c70dfc5
Commit
2c70dfc5
authored
6 years ago
by
Mark OLESEN
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add pdf option to foamCreateManpage
parent
603dd28f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/tools/foamCreateManpage
+58
-22
58 additions, 22 deletions
bin/tools/foamCreateManpage
with
58 additions
and
22 deletions
bin/tools/foamCreateManpage
+
58
−
22
View file @
2c70dfc5
...
@@ -27,8 +27,9 @@ usage() {
...
@@ -27,8 +27,9 @@ usage() {
Usage:
${
0
##*/
}
[OPTION] [appName .. [appNameN]]
Usage:
${
0
##*/
}
[OPTION] [appName .. [appNameN]]
options:
options:
-dir dir Directory to process
-dir dir Directory to process
-gzip Compressed output
-gzip Compressed manpage output
-o DIR Write to alternative output directory
-pdf Process as manpage and pass to ps2pdf
-output DIR Write to alternative output directory
-version VER Specify an alternative version
-version VER Specify an alternative version
-h | -help Print the usage
-h | -help Print the usage
...
@@ -59,7 +60,7 @@ die()
...
@@ -59,7 +60,7 @@ die()
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
searchDirs
=
"
$FOAM_APPBIN
"
searchDirs
=
"
$FOAM_APPBIN
"
unset
gzipFilter
sedFilter outputDir
unset
sedFilter outputDir
outputType
while
[
"$#"
-gt
0
]
while
[
"$#"
-gt
0
]
do
do
...
@@ -67,14 +68,17 @@ do
...
@@ -67,14 +68,17 @@ do
-h
|
-help
*
)
-h
|
-help
*
)
usage
usage
;;
;;
-d
|
-dir
)
-dir
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
searchDirs
=
"
$2
"
searchDirs
=
"
$2
"
[
-d
"
$searchDirs
"
]
||
die
"directory not found '
$searchDirs
'"
[
-d
"
$searchDirs
"
]
||
die
"directory not found '
$searchDirs
'"
shift
shift
;;
;;
-gz
|
-gzip
)
-gz
|
-gzip
)
gzipFilter
=
"gzip"
outputType
=
"gz"
;;
-pdf
)
outputType
=
"pdf"
;;
;;
-v
|
-version
)
-v
|
-version
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
...
@@ -100,52 +104,84 @@ done
...
@@ -100,52 +104,84 @@ done
:
${
outputDir
:
=
$defaultOutputDir
}
:
${
outputDir
:
=
$defaultOutputDir
}
# Verify that output is writeable
# Verify that output is writeable
if
[
-e
"
$outputDir
"
]
if
[
-e
x
"
$outputDir
"
]
then
then
[
-d
"
$outputDir
"
]
&&
[
-w
"
$outputDir
"
]
||
\
[
-d
"
$outputDir
"
]
&&
[
-w
"
$outputDir
"
]
||
\
die
"Cannot write to
$outputDir
"
"Not a directory, or no permission?"
die
"Cannot write to
$outputDir
"
"Not a directory, or no permission?"
else
else
mkdir
-p
"
$outputDir
"
||
\
mkdir
-p
"
$outputDir
"
2> /dev/null
||
\
die
"Cannot create directory:
$outputDir
"
die
"Cannot create directory:
$outputDir
"
fi
fi
#-------------------------------------------------------------------------------
echo
"Generating manpages from OpenFOAM applications"
1>&2
echo
1>&2
# Pass through content, filter for version and/or gzip
#
tmpFile
=
"
$outputDir
/
${
0
##*/
}
"
# Use a tmp file so that we confirm that the content was
# generated and looks somewhat like a manpage (has a SYNOPSIS)
tmpFile
=
"
$outputDir
/
${
0
##*/
}
-tmp
$$
"
trap
"rm -fv
$tmpFile
>/dev/null; exit 0"
EXIT TERM INT
trap
"rm -fv
$tmpFile
>/dev/null; exit 0"
EXIT TERM INT
# Any special filter requirements?
# Default extension is "1" for manpage
outputExt
=
"1"
case
"
$outputType
"
in
pdf
)
outputExt
=
"pdf"
command
-v
groff
>
/dev/null
||
die
"Missing program: groff"
command
-v
ps2pdf
>
/dev/null
||
die
"Missing program: ps2pdf"
;;
gz
)
outputExt
=
"1.gz"
command
-v
gzip
>
/dev/null
||
die
"Missing program: gzip"
;;
esac
#-------------------------------------------------------------------------------
# Get nroff man content from application, store in tmp file for checking
# and output / filter
# 1 = application
process
()
process
()
{
{
local
appName
=
"
$1
"
local
appName
=
"
$1
"
local
outFile
=
"
$outputDir
/
${
appName
##*/
}
.1
"
local
outFile
=
"
$outputDir
/
${
appName
##*/
}
"
rm
-f
"
$outFile
"
*
;
rm
-f
"
$outFile
"
*
;
"
$appName
"
-help-man
2>/dev/null
>
|
$tmpFile
;
"
$appName
"
-help-man
|
sed
-e
"
${
sedFilter
}
"
2>/dev/null
>
|
"
$tmpFile
"
# Check that it looks ok
if
grep
-F
-q
"SYNOPSIS"
"
$tmpFile
"
2>/dev/null
if
grep
-F
-q
"SYNOPSIS"
"
$tmpFile
"
2>/dev/null
then
then
cat
"
$tmpFile
"
|
\
case
"
$outputType
"
in
sed
-e
"
${
sedFilter
}
"
|
"
${
gzipFilter
:-
cat
}
"
\
pdf
)
>
|
"
$outFile
${
gzipFilter
:+.gz
}
"
groff
-man
"
$tmpFile
"
| ps2pdf -
"
$outFile
.
$outputExt
"
;;
gz
)
gzip
-c
"
$tmpFile
"
>
|
"
$outFile
.
$outputExt
"
;;
*
)
\c
p
-f
"
$tmpFile
"
"
$outFile
.
$outputExt
"
;;
esac
echo
"
$outFile
${
gzipFilter
:+.gz
}
"
1>&2
echo
"
$outFile
.
$outputExt
"
1>&2
else
else
echo
"Problem with
$appName
"
1>&2
echo
"Problem with
$
{
appName
##*/
}
"
1>&2
fi
fi
}
}
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Default to standard search directories
# Default to standard search directories
[
"$#"
-gt
0
]
||
set
--
${
searchDirs
}
[
"$#"
-gt
0
]
||
set
--
${
searchDirs
}
echo
"Generating manpages from OpenFOAM applications"
1>&2
echo
1>&2
for
item
for
item
do
do
if
[
-d
"
$item
"
]
if
[
-d
"
$item
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment