1 # ============================================================================
2 # Copyright (c) 2011-2012 University of Pennsylvania
3 # Copyright (c) 2013-2016 Andreas Schuh
6 # See COPYING file for license information or visit
7 # https://cmake-basis.github.io/download.html#license
8 # ============================================================================
10 ##############################################################################
11 # @file DoxyFilter/Bash.pm
12 # @brief Doxygen filter for Bash.
15 ##############################################################################
17 package BASIS::DoxyFilter::Bash;
18 use base BASIS::DoxyFilter;
20 # ============================================================================
22 # ============================================================================
24 # ----------------------------------------------------------------------------
25 ## @brief Constructs a CMake Doxygen filter.
31 ['start', qr/^\s*if\s*\[/, undef, 'start'], # discard if's such that
33 # associated with next
34 # block that is supposed
35 # to be in the then branch.
37 ['start', qr/^\s*(\.|source)\s+(\"([^\"]|\\\")*[^\\]\"|'([^']|\\')*[^\\]'|[^\s&|]*)(\s*(\|\||&&|#).*)?$/, \&_source, 'start'],
39 ['start', qr/^\s*(\[\s+.*\s+\]\s*(\|\||&&)\s*|if\s+\[\s+.*\s+\]\s*;\s*then\s+)?readonly\s+(\w+)=(\"([^\"]|\\\")*[^\\]\"|'([^']|\\')*[^\\]'|[^#]*)(\s*;\s*fi\s*)?(\s*#.*)?$/, \&_constant, 'start'],
41 ['start', qr/^\s*(function\s*(\w+)|(\w+)\s*\(\s*\))\s*{\s*(#.*)?$/, \&_fndef, 'fnbody'],
42 ['start', qr/^\s*(function\s*(\w+)|(\w+)\s*\(\s*\))\s*(#.*)?$/, \&_fndef, 'fndef'],
43 ['fndef', qr/^{\s*(#.*)?$/, undef, 'fnbody'],
44 ['fnbody', qr/^}\s*(#.*)?$/, undef, 'start'],
48 # ============================================================================
50 # ============================================================================
52 # ----------------------------------------------------------------------------
55 my ($self, $unused, $module) = @_;
56 $module =~ s/^\s*[\"']?//;
57 $module =~ s/[\"']?\s*$//;
58 $module =~ s/\/.\//\//g;
59 $module =~ s/^\${_\w+_DIR}\///;
60 $module =~ s/^\$\(exedir\)\///;
61 $module =~ s/^\${?exec_dir}?\///;
62 $self->_append("#include \"$module\"");
65 # ----------------------------------------------------------------------------
68 my ($self, $unused1, $unused2, $name, $value) = @_;
72 $value =~ s/^\s*[\"']?//;
73 $value =~ s/[\"']?\s*$//;
74 if ($value =~ /^[+-]?[0-9]+$/) {
75 $self->_append("int $name = $value;");
76 } elsif ($value =~ /^[+-]?[0-9]+[.][0-9]+$/) {
77 $self->_append("float $name = $value;");
79 $self->_append("string $name = \"$value\";");
84 # ----------------------------------------------------------------------------
87 my ($self, $unused, $name1, $name2) = @_;
88 my $name = $name1 ? $name1 : $name2;
93 foreach my $paramdoc (@{$self->{'params'}}) {
94 push @params, $paramdoc->{'dir'} . " " . $paramdoc->{'name'};
96 $self->_append("/// \@returns Nothing.") if not $self->{'returndoc'};
97 $self->_append("function $name(" . join(', ', @params) . ");");