2012-10-23 52 views

回答

1

使用生成它們:javadoc的*的.java,然後只要你想重寫stylesheet.css中......

+0

號的OP在談論的不僅僅是改變了樣式的更多。 –

+0

thx爲簡單命令 –

0

作爲替代方案,您可能會考慮我寫的一個類,名爲FilteredLineIterator,它可用於從源文件中刪除所有JavaDoc行。

(這個答案是一個類似於我在this question寫道。)

一個FilteredLineIterator是一個字符串迭代器,過濾器(保留或抑制)在另一迭代器的元素,基於「實體」(單線,塊和「隱形」塊),每行存在。保留行可以選擇修改。

FilteredLineIteratorXBN-Java部分罐子可以下載here。)

實施例的頂部和設置:

import com.github.xbn.linefilter.FilteredLineIterator; 
    import com.github.xbn.linefilter.KeepUnmatched; 
    import com.github.xbn.linefilter.Returns; 
    import com.github.xbn.linefilter.entity.BlockEntity; 
    import com.github.xbn.linefilter.entity.EntityRequired; 
    import com.github.xbn.linefilter.entity.KeepMatched; 
    import com.github.xbn.linefilter.entity.NewBlockEntityFor; 
    import com.github.xbn.linefilter.entity.NewStealthBlockEntityFor; 
    import com.github.xbn.linefilter.entity.StealthBlockEntity; 
    import com.github.xbn.testdev.GetFromCommandLineAtIndex; 
    import com.github.xbn.util.IncludeJavaDoc; 
    import java.util.Iterator; 
/** 
    <P>{@code java ExtractAllJavaDocBlockTextRaw examples\com\github\xbn\examples\linefilter\JavaClassWithOneCommentAndTwoJavaDocBlocks_input.txt}</P> 
**/ 
public class ExtractAllJavaDocBlockTextRaw { 
    public static final void main(String[] cmd_lineParams) { 
    //Example setup: 
     Iterator<String> rawInputLineItr = GetFromCommandLineAtIndex.fileLineIterator(
      cmd_lineParams, 0, 
      null); //debugPath 

主要部分的下方開始。 JavaDoc塊定義爲block entity,其中只保留中間(不是開始或結束)行。爲了防止在塊打開前發現錯誤的「結束行」錯誤 - 由於JavaDoc和「正常」(非JavaDoc)多行註釋的結束行爲*/ - 必須聲明正常多行註釋的a stealth block

輸入的原始行迭代器和兩個實體都被饋送到過濾的行迭代器。

 StealthBlockEntity javaMlcBlock = NewStealthBlockEntityFor.javaComment(
     "comment", IncludeJavaDoc.NO, 
     null,  //dbgStart (on=System.out, off=null) 
     null,  //dbgEnd 
     KeepMatched.NO, EntityRequired.YES, null, 
     null);  //dbgLineNums 

    BlockEntity javaDocBlock = NewBlockEntityFor.javaDocComment_Cfg(
     "doccomment", 
     null,  //dbgStart 
     null,  //dbgEnd 
     EntityRequired.YES, null, 
     null).  //dbgLineNums 
     keepMidsOnly().build(); 

    FilteredLineIterator filteredItr = new FilteredLineIterator(
     rawInputLineItr, Returns.KEPT, KeepUnmatched.NO, 
     null, null, //dbgEveryLine and its line-range 
     javaMlcBlock, javaDocBlock); 

    while(filteredItr.hasNext()) { 
     System.out.println(filteredItr.next()); 
    } 
    } 
} 

輸出(輸入文件是在此答案形柱的底部):

 <P>The main class JavaDoc block.</P> 
     <P>Constructor JavaDoc block</P> 
     * <P>Function JavaDoc block.</P> 

     * <P>This function does some stuff.</P> 

     * <P>Lots and lots of stuff.</P> 

爲了從每條線剝去可選星號,包括前述任一項的空白,添加一個「中線alterer 「來的JavaDoc塊實體:

TextLineAlterer asteriskStripper = NewTextLineAltererFor.replacement(
    Pattern.compile("[ \t]*(?:\\*[ \t]*)?(.*)"), "$1", 
    ReplacedInEachInput.FIRST, 
    null,  //debug 
    null); 

通過改變keepMidsOnly().build();

的alterer添加到該塊實體
midAlter(asteriskStripper).keepMidsOnly().build(); 

輸出:

<P>The main class JavaDoc block.</P> 
<P>Constructor JavaDoc block</P> 
<P>Function JavaDoc block.</P> 

<P>This function does some stuff.</P> 

<P>Lots and lots of stuff.</P> 

輸入文件:

/* 
    A Java comment block. 
*/ 
package fully.qualified.package.name; 
/** 
    <P>The main class JavaDoc block.</P> 
*/ 
public class StayClassy { 
    /** 
     <P>Constructor JavaDoc block</P> 
    */ 
    public StayClassy() { 
     //Do stuff 
    } 
    /** 
     * <P>Function JavaDoc block.</P> 

     * <P>This function does some stuff.</P> 

     * <P>Lots and lots of stuff.</P> 
    */ 
    public void doStuff() { 
    } 
}