Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand All @@ -30,11 +34,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -43,7 +47,7 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Setup Java JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -52,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -66,4 +70,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ lib/
tmp/
codavaj-*.jar
java8.properties
AGENTS.md
95 changes: 69 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
[![Releases](https://jitpack.io/v/umjammer/codavaj.svg)](https://jitpack.io/#umjammer/codavaj)
[![Actions Status](https://github.com/umjammer/codavaj/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/codavaj/actions)
[![Java CI](https://github.com/umjammer/codavaj/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/codavaj/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/codavaj/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/codavaj/actions/workflows/codeql-analysis.yml)
![Java](https://img.shields.io/badge/Java-8-b07219)
![Java](https://img.shields.io/badge/Java-17-b07219)

# CODAVAJ - ( javadoc in reverse ) README
# CODAVAJ

## Convert Javadoc to Java Source
<img alt="logo" src="https://github.com/umjammer/codavaj/assets/493908/ef56b6d5-1c11-4859-a780-94f80643fa2d" width="100" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<sub>codavaj is anadrome of javadoc</sub>

to convert javadoc tree into java source (external references to Sun's
standard javadocs are automatically resolved
i.e. `http://java.sun.com/j2se/1.5.0/docs/api/`)
## Install

```
codavaj.cmd codavaj <javadoc-dir> <javasource-dir> {<external-link-url>}*
```
* https://jitpack.io/#umjammer/codavaj

i.e.
## Usage

```
codavaj.cmd codavaj tmp/jumpi/javadoc tmp/jumpi/src
```
### Convert Javadoc to Java Source

or
to convert javadoc tree into java source<br/>
(external references to Sun's standard javadocs are automatically resolved
i.e. `http://java.sun.com/j2se/1.5.0/docs/api/`)

```
codavaj.cmd codavaj tmp/jumpi/javadoc tmp/jumpi/src http://external.link.com/api
codavaj.cmd codavaj <javadoc-dir> <javasource-dir> {<external-link-url>}*
```

or
#### i.e.

```
codavaj.cmd codavaj http://jumpi.sourceforge.net/javadoc/j2se tmp/jumpi/src
```shell
$ # from LOCAL javadoc
$ codavaj.cmd codavaj tmp/jumpi/javadoc tmp/jumpi/src
$ # or from local javadoc w/ EXTERNAL LINK
$ codavaj.cmd codavaj tmp/jumpi/javadoc tmp/jumpi/src http://external.link.com/api
$ # or from REMOTE javadoc
$ codavaj.cmd codavaj http://jumpi.sourceforge.net/javadoc/j2se tmp/jumpi/src
```

## Cooperate with Java Parser
### Cooperate with Java Parser

| **parser** | **set javadoc to (decompiled) source** | **rename argument names as javadoc documented** | **code** | **output** |
|:-----------|:--------------------------------------:|:-----------------------------------------------:|------------------------------------------------------------------------------------------------------------|:--------------------------------:|
Expand All @@ -42,18 +43,56 @@ codavaj.cmd codavaj http://jumpi.sourceforge.net/javadoc/j2se tmp/jumpi/src
| [JDT](https://www.eclipse.org/jdt/) | ✅ | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/JgtCommentator.java) | little bit worse than JavaParser |
| [spoon](https://github.com/INRIA/spoon) | ✅ | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/SpoonCommentator.java) | formats are gone |

## known issues
#### Example

```shell
$ # install codavaj
$ cd $HOME/src/java
$ git clone https://github.com/umjammer/codavaj

$ # decompile by fernflower
$ cd $HOME/src/java/javax-speech
$ curl -o tmp/speech-1.0.0.jar https://github.com/umjammer/umjammer/raw/mvn-repo/javax/speech/speech/1.0.0/speech-1.0.0.jar
$ mkdir -p tmp/classes
$ java -jar fernflower.jar tmp/speech-1.0.0.jar tmp/classes
$ pushd src/main/java; jar xvf $HOME/src/java/javax-speech/tmp/classes/speech-1.0.0.jar; popd

$ # add comment from javadoc on the net to decompiled source
$ cd $HOME/src/java/javax-speech
$ mkdir -p src/main/java
$ mkdir -p tmp/src
$ (pushd $HOME/src/java/codavaj; mvn -P comment test-compile antrun:run@javaParser \
-Dcomment.javadoc=https://docs.oracle.com/cd/E17802_01/products/products/java-media/speech/forDevelopers/jsapi-doc \
-Dcomment.source=$HOME/src/java/javax-speech/src/main/java \
-Dcomment.out=$HOME/src/java/javax-speech/tmp/src \
; popd)
$ diff -rBw src/main/java tmp/src | less -R
$ diff -rBw src/main/java tmp/src > tmp/c.patch
$ pushd src/main/java; patch -p 2 < ../../../tmp/c.patch; popd
```

### known issues

* codavaj does not introduce default constructor's if they weren't found
in the javadoc. This leads to compile problems if there are subclasses
which use the class's default constructor through the implicit super().
* codavaj does not introduce default constructor's if they weren't found
in the javadoc. This leads to compile problems if there are subclasses
which use the class's default constructor through the implicit super().

* nekohtml ~1.19.22
* nekohtml ~1.19.22
* https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml/1.9.22
* https://mvnrepository.com/artifact/xerces/xercesImpl/2.11.0
* but 1.19.22 doesn't work with this project currently
* so i excluded xerces from dependencies, and add xerces 2.12.2 individually. idk how codeql detect those.
* https://sourceforge.net/p/nekohtml/bugs/167/#fdcc

* @see split too much by arguments' separator ","
* override methods after 2nd.'s comment are gone
* h hags
* code tag
* ol, ul, li tag

## References

* https://docs.openrewrite.org/

## TODO

Expand All @@ -62,4 +101,8 @@ which use the class's default constructor through the implicit super().
* ~~javadoc 11~~
* ~~en test case~~
* https://github.com/HtmlUnit/htmlunit-neko
* https://github.com/HtmlUnit/htmlunit-neko/security/advisories/GHSA-6jmm-mp6w-4rrg
* https://github.com/HtmlUnit/htmlunit-neko/security/advisories/GHSA-6jmm-mp6w-4rrg
TODO
* use vavi-util-screenscraping?
* interface default
* ~~Spoon~~
3 changes: 0 additions & 3 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
jdk:
- openjdk17
before_install:
- sdk install java 17.0.1-open
- sdk use java 17.0.1-open
Loading
Loading