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
Branches
Branches containing commit
Tags
Tags containing commit
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() {
Usage:
${
0
##*/
}
[OPTION] [appName .. [appNameN]]
options:
-dir dir Directory to process
-gzip Compressed output
-o DIR Write to alternative output directory
-gzip Compressed manpage output
-pdf Process as manpage and pass to ps2pdf
-output DIR Write to alternative output directory
-version VER Specify an alternative version
-h | -help Print the usage
...
...
@@ -59,7 +60,7 @@ die()
#-------------------------------------------------------------------------------
searchDirs
=
"
$FOAM_APPBIN
"
unset
gzipFilter
sedFilter outputDir
unset
sedFilter outputDir
outputType
while
[
"$#"
-gt
0
]
do
...
...
@@ -67,14 +68,17 @@ do
-h
|
-help
*
)
usage
;;
-d
|
-dir
)
-dir
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
searchDirs
=
"
$2
"
[
-d
"
$searchDirs
"
]
||
die
"directory not found '
$searchDirs
'"
shift
;;
-gz
|
-gzip
)
gzipFilter
=
"gzip"
outputType
=
"gz"
;;
-pdf
)
outputType
=
"pdf"
;;
-v
|
-version
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
...
...
@@ -100,52 +104,84 @@ done
:
${
outputDir
:
=
$defaultOutputDir
}
# Verify that output is writeable
if
[
-e
"
$outputDir
"
]
if
[
-e
x
"
$outputDir
"
]
then
[
-d
"
$outputDir
"
]
&&
[
-w
"
$outputDir
"
]
||
\
die
"Cannot write to
$outputDir
"
"Not a directory, or no permission?"
else
mkdir
-p
"
$outputDir
"
||
\
mkdir
-p
"
$outputDir
"
2> /dev/null
||
\
die
"Cannot create directory:
$outputDir
"
fi
#-------------------------------------------------------------------------------
# Pass through content, filter for version and/or gzip
#
echo
"Generating manpages from OpenFOAM applications"
1>&2
echo
1>&2
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
# 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
()
{
local
appName
=
"
$1
"
local
outFile
=
"
$outputDir
/
${
appName
##*/
}
.1
"
local
outFile
=
"
$outputDir
/
${
appName
##*/
}
"
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
then
cat
"
$tmpFile
"
|
\
sed
-e
"
${
sedFilter
}
"
|
"
${
gzipFilter
:-
cat
}
"
\
>
|
"
$outFile
${
gzipFilter
:+.gz
}
"
case
"
$outputType
"
in
pdf
)
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
echo
"Problem with
$appName
"
1>&2
echo
"Problem with
$
{
appName
##*/
}
"
1>&2
fi
}
#------------------------------------------------------------------------------
# Default to standard search directories
[
"$#"
-gt
0
]
||
set
--
${
searchDirs
}
echo
"Generating manpages from OpenFOAM applications"
1>&2
echo
1>&2
for
item
do
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