3 Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
4 Copyright [2016-2024] EMBL-European Bioinformatics Institute
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
21 # =======================================================================
22 # Doxygen Pre-Processor for Perl
23 # Copyright (C) 2002 Bart Schuller
24 # Copyright (C) 2006 Phinex Informatik AG
27 # Doxygen Filter is free software; you can redistribute it and/or modify
28 # it under the same terms as Perl itself.
30 # Larry Wall's 'Artistic License' for perl can be found in
31 # http://www.perl.com/pub/a/language/misc/Artistic.html
33 # =======================================================================
35 # Author: Aeby Thomas, Phinex Informatik AG,
36 # Based on DoxygenFilter from Bart Schuller
37 # E-Mail: tom.aeby@phinex.ch
39 # Phinex Informatik AG
44 # =======================================================================
48 # Revision History prior to import into EnsEMBL:
50 # Revision 1.1 2011-10-18 13:46:34 kt7
51 # Transferring Doxygen filter into EnsEMBL CVS.
53 # Revision 1.1 2011-05-16 15:31:44 kt7
54 # Preservative backup of all code required to run Doxygen to
55 # generate API reference.
57 # Revision 1.2 2006/01/31 16:53:52 aeby
58 # added copyright info
61 # =======================================================================
64 # implementation of Filter as derrived from Doxygen::Filter.
68 # Filter from non-C++ syntax API docs to Doxygen-compatible syntax.
69 # This class is meant to be used as a filter for the
70 # <a href="http://www.doxygen.org/">Doxygen</a> documentation tool.
71 package EnsEMBL::Filter;
76 my $debug_home_location =
'';
77 if($ENV{PERL_DOXYGEN_DEBUG_LOCATION}) {
78 $debug_home_location = $ENV{PERL_DOXYGEN_DEBUG_LOCATION};
81 ## @cmethod object new($outfh)
82 # create a filter object.
83 # @param outfh optional output filehandle; defaults to STDOUT
84 # @return filter object
87 my $outfh = shift || \*STDOUT;
89 my $self = bless {outfh => $outfh}, $class;
91 if($debug_home_location) {
92 open(my $debug,
'>', $debug_home_location);
93 $self->{debug_fh} = $debug;
101 close $self->{debug_fh}
if $self->{debug_fh};
105 ## @method virtual void filter($infh)=0
107 # @param infh input filehandle, normally STDIN
109 die
"subclass responsibility";
112 ## @method protected string protection($sig)
113 # Return the protection of a method/function signature.
114 # @param sig the method signature
115 # @return Either "Public" or "Private".
117 my($self, $sig) = @_;
118 return $sig =~ /^(
private|
protected)/ ?
"\u$1" :
'Public';
121 ## @method void start($command)
122 # start a doc comment.
123 # Outputs the start of a javadoc comment.
124 # @param command the javadoc command
128 $self->print(
"/** $command\n");
132 ## @method void end()
134 # Outputs the end of a javadoc comment.
136 my ($self, $tag) = @_;
139 $self->print(
"$tag */\n");
143 $self->print(
"*/\n");
148 ## @method void push($section)
149 # Start a diversion to a section.
150 # @param section The name of the section to divert all output to.
151 # @see pop(), print(), flush()
153 my($self, $section) = @_;
154 $self->{current_section} = $section;
158 ## @method void pop()
159 # End a diversion to a section.
160 # @see push(), flush()
163 delete $self->{current_section};
167 ## @method void print(@args)
168 # print a string to the output handle.
169 # If a diversion to a specific section is in effect: saves the text under
171 # @param args the strings to be printed
172 # @see push(), flush()
176 if (my $section = $self->{current_section}) {
177 CORE::push @{$self->{sections}{$section}}, @_;
179 my $outfh = $self->{outfh};
181 my $debug_fh = $self->{debug_fh};
182 print $debug_fh @_
if $debug_fh;
194 ## @method void more(@args)
195 # process the follow-up lines after the initial apidoc line.
196 # @param args the lines to be processed
204 'Public Class Methods',
205 'Public Object Methods',
207 'Protected Class Methods',
208 'Protected Object Methods',
209 'Protected Functions',
210 'Private Class Methods',
211 'Private Object Methods',
214 ## @method void flush()
215 # Flush the saved sections. Should be called at the end of a class.
216 # @see push(), print()
219 my $sections = $self->{sections};
221 next unless $sections->{$_};
222 $self->start(
"\@name $_\n")->end;
223 $self->start(
"\@{")->end;
225 $self->print(@{$sections->{$_}});
227 $self->start(
"\@}")->end;
230 delete $self->{sections};
244 Filter from non-C++ syntax API docs to Doxygen-compatible syntax.
245 This
class is meant to be used as a filter for the