项目作者: qwefgh90

项目描述 :
The Comment Parser supports various languages based on FSM. It's written by scala and java.
高级语言: Scala
项目地址: git://github.com/qwefgh90/comment-parser.git
创建时间: 2017-11-17T08:15:14Z
项目社区:https://github.com/qwefgh90/comment-parser

开源协议:Apache License 2.0

下载


Comment Parser

The Comment Parser supports various languages based on FSM. It’s written by scala and java.

Prerequisites

  • Java 1.8

Getting comment parser

Comment Parser is published to Sonatype OSS and Maven Central:

  • Group id / organization: io.github.qwefgh90
  • Artifact id / name: comment-parser
  • Latest version is 0.1.0

Add it to your sbt build definition:

  1. libraryDependencies += "io.github.qwefgh90" %% "comment-parser" % "0.1.0"

Add one of them to your maven pom file:

  1. <dependency>
  2. <groupId>io.github.qwefgh90</groupId>
  3. <artifactId>comment-parser_2.11</artifactId>
  4. <version>0.1.0</version>
  5. </dependency>

or

  1. <dependency>
  2. <groupId>io.github.qwefgh90</groupId>
  3. <artifactId>comment-parser_2.11</artifactId>
  4. <version>0.1.0</version>
  5. </dependency>

Using Comment Parser

CommentParser is a main class to extract comments from various files. Import io.github.qwefgh90.commentparser package to your sources to use CommentParser. Also, there is a inner CommentParser.CommentResult class containing a result.

It has four static methods to do that.

You can pass URI object to first parameter.

  1. import io.github.qwefgh90.commentparser.CommentParser;
  2. import java.nio.file.Paths;
  3. import java.util.Optional;
  4. import java.util.List;
  5. Optional<java.util.List<CommentParser.CommentResult>> result = CommentParser.extractComments(Paths.get("C:\\java.java").toUri(), "java.java");

InputStream object can be used to first parameter.

  1. import io.github.qwefgh90.commentparser.CommentParser;
  2. import java.nio.file.Paths;
  3. import java.io.InputStream;
  4. import java.io.File;
  5. import java.util.Optional;
  6. import java.util.List;
  7. File f = Paths.get("C:\\java.java").toFile();
  8. InputStream is = new FileInputStream(f);
  9. Optional<java.util.List<CommentParser.CommentResult>> result = CommentParser.extractComments(is, "java.java");
  10. is.close();

You can pass Charset object to third parameter optionally.

  1. import io.github.qwefgh90.commentparser.CommentParser;
  2. import java.nio.file.Paths;
  3. import java.nio.charset.StandardCharsets;
  4. import java.util.Optional;
  5. import java.util.List;
  6. Optional<java.util.List<CommentParser.CommentResult>> result = CommentParser.extractComments(Paths.get("C:\\java.java").toUri(), "java.java", StandardCharsets.UTF_8);

For more information, You can check API document.

Supported Languages

  • JAVA
  • PY
  • C
  • CPP
  • C_HEADER
  • CPP_HEADER
  • SCALA
  • RUBY
  • GO
  • JS
  • HTML
  • BAT
  • SH
  • XML
  • TEXT
  • MD
  • ETC

Compile & Test

  • sbt compile
  • sbt test