Ignore:
Timestamp:
11/24/08 14:27:56 (4 years ago)
Author:
CrawfordCurrie
Message:

Item287: Rewrote significant chunk of plugins doc to simplify and improve developer doc. Added doc: protocol to %INCLUDE to support including core module documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/lib/Foswiki.pm

    r840 r920  
    193193        ATTACHURL         => \&ATTACHURL, 
    194194        ATTACHURLPATH     => \&ATTACHURLPATH, 
     195        COREPOD           => \&COREPOD, 
    195196        DATE              => \&DATE, 
    196197        DISPLAYTIME       => \&DISPLAYTIME, 
     
    35533554      || $this->{prefs}->getPreferencesValue('INCLUDEWARNING'); 
    35543555 
    3555     if ( $path =~ /^https?\:/ ) { 
     3556    if ( $path =~ /^https?:/ ) { 
    35563557 
    35573558        # include web page 
    3558         return _includeUrl( $this, $path, $pattern, $includingWeb, 
     3559        return $this->_includeUrl( $path, $pattern, $includingWeb, 
    35593560            $includingTopic, $raw, $params, $warn ); 
     3561    } 
     3562 
     3563    if ( $path =~ s/^doc:// ) { 
     3564 
     3565        # include web page 
     3566        return $this->_includeCodeDoc( $path, $pattern, $params ); 
    35603567    } 
    35613568 
     
    45054512 
    45064513    return '| *Group* | *Members* |' . "\n" . join( "\n", sort @table ); 
     4514} 
     4515 
     4516# Include embedded doc in a core module 
     4517sub _includeCodeDoc { 
     4518    my ( $this, $class, $pattern, $params ) = @_; 
     4519 
     4520    return '' unless $class && $class =~ /^Foswiki/; 
     4521    $class =~ s/[^\w:]//g; 
     4522 
     4523    my $pmfile; 
     4524    $class =~ s#::#/#g; 
     4525    foreach my $inc (@INC) { 
     4526        if ( -f "$inc/$class.pm" ) { 
     4527            $pmfile = "$inc/$class.pm"; 
     4528            last; 
     4529        } 
     4530    } 
     4531    return '' unless $pmfile; 
     4532 
     4533    open( PMFILE, '<', $pmfile ) || return ''; 
     4534    my $inPod = 0; 
     4535    my $pod = ''; 
     4536    local $/ = "\n"; 
     4537    while ( my $line = <PMFILE> ) { 
     4538        if ( $line =~ /^=(begin|pod)/ ) { 
     4539            $inPod = 1; 
     4540        } 
     4541        elsif ( $line =~ /^=cut/ ) { 
     4542            $inPod = 0; 
     4543        } 
     4544        elsif ($inPod) { 
     4545            $pod .= $line; 
     4546        } 
     4547    } 
     4548    close(PMFILE); 
     4549 
     4550    $pod =~ s/.*?%STARTINCLUDE%//s; 
     4551    $pod =~ s/%STOPINCLUDE%.*//s; 
     4552 
     4553    $pod = applyPatternToIncludedText( $pod, $pattern ) if ($pattern); 
     4554 
     4555    # Adjust the root heading level 
     4556    if ( $params->{level} ) { 
     4557        my $minhead = '+' x 100; 
     4558        $pod =~ s/^---(\++)/ 
     4559          $minhead = $1 if length($1) < length($minhead); "---$1"/gem; 
     4560        return $pod if length($minhead) == 100; 
     4561        my $newroot = '+' x $params->{level}; 
     4562        $minhead =~ s/\+/\\+/g; 
     4563        $pod =~ s/^---$minhead/---$newroot/gm; 
     4564    } 
     4565    return $pod; 
    45074566} 
    45084567 
Note: See TracChangeset for help on using the changeset viewer.