Skip to content

Commit e788c95

Browse files
authored
Fix/docs nav (#624)
* Fixing javadoc generation scripts * Add docs nav and landing page * Update JavaCPP notice * Renamed tools to legacy * Delete old docs scripts * Add mention for legacy doc tools
1 parent cbf9420 commit e788c95

File tree

89 files changed

+313
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+313
-127
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ gradleBuild
6464
# Deployment Files
6565
settings.xml
6666
pom.xml.asc
67+
68+
# Docs
69+
docs/docs/apidocs/

docs/_toc.yaml

100644100755
File mode changed.

docs/docs/assets/tensorflow.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/index.md renamed to docs/docs/index.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# TensorFlow for Java
22

3-
<table class="tfo-notebook-buttons" align="left">
4-
<td>
5-
<a target="_blank" href="https://www.tensorflow.org/jvm"><img src="https://www.tensorflow.org/images/tf_logo_32px.png" />View on TensorFlow.org</a>
6-
</td>
7-
<td>
8-
<a target="_blank" href="https://github.com/tensorflow/java"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />View GitHub repository</a>
9-
</td>
10-
</table>
11-
123
TensorFlow Java can run on any JVM for building, training and running machine learning models. It comes with
134
a series of utilities and frameworks that help achieve most of the tasks common to data scientists
145
and developers working in this domain. Java and other JVM languages, such as Scala or Kotlin, are
@@ -26,21 +17,19 @@ migrated from Bazel to Maven, which is more familiar for most Java developers.
2617

2718
The following describes the layout of the repository and its different artifacts:
2819

29-
* [tensorflow-core](https://github.com/tensorflow/java/tree/master/tensorflow-core)
30-
* All artifacts that build up the core language bindings of TensorFlow for Java
31-
* Intended audience: projects that provide their own APIs or frameworks on top of
32-
TensorFlow and just want a thin layer to access the TensorFlow runtime from the JVM
33-
34-
* [tensorflow-framework](https://github.com/tensorflow/java/tree/master/tensorflow-framework)
35-
* Primary API for building and training neural networks with TensorFlow
36-
* Intended audience: neural network developers
20+
### [tensorflow-core](https://github.com/tensorflow/java/tree/master/tensorflow-core)
21+
* **Intended audience**: developers who wants to deploy a TensorFlow model on a JVM for inference. Also for projects
22+
that provide their own APIs or frameworks on top of TensorFlow and just want a thin layer to access the TensorFlow runtime from the JVM.
23+
* All artifacts that make up the core language bindings of TensorFlow for Java.
3724

38-
* [ndarray](https://github.com/tensorflow/java-ndarray)
39-
* Generic utility library for n-dimensional data I/O operations
40-
* Used by TensorFlow but does not depend on TensorFlow
41-
* Intended audience: any developer who needs a Java n-dimensional array implementation, whether or not they
42-
use it with TensorFlow
25+
### [tensorflow-framework](https://github.com/tensorflow/java/tree/master/tensorflow-framework)
26+
* **Intended audience**: neural network developers.
27+
* Primary API for building and training neural networks with TensorFlow.
4328

29+
### [ndarray](https://github.com/tensorflow/java-ndarray)
30+
* **Intended audience**: any developer who needs a Java n-dimensional array implementation, whether or not they use it with TensorFlow.
31+
* Generic utility library for n-dimensional data I/O operations.
32+
* Used by TensorFlow but does not depend on TensorFlow.
4433

4534
## Communication
4635

docs/install.md renamed to docs/docs/install.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ TensorFlow Java 1.0 series and earlier releases also have binaries for:
2525

2626
* macOS 12 or higher; 64-bit, x86
2727

28-
*Note: To use TensorFlow on Android, see
29-
[TensorFlow Lite](https://tensorflow.org/lite)*
28+
*Note: To use TensorFlow on Android, see [LiteRT](https://tensorflow.org/lite)*
3029

3130
## Versions
3231

docs/docs/references.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
hide:
3+
- navigation
4+
- toc
5+
- title
6+
---
7+
#
8+
<iframe src="https://tensorflow.github.io/java/javadoc/v1.2.0/index.html" style="width:100%; height:800px; border:none;"></iframe>

docs/docs/stylesheets/extra.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
:root > * {
2+
/*--md-primary-fg-color: #EE782F;*/
3+
/*--md-primary-fg-color--light: #455960;*/
4+
/*--md-primary-fg-color--dark: #90030C;*/
5+
}
6+
7+
.md-typeset h1, .md-typeset h2 {
8+
font-weight: 800;
9+
letter-spacing: -.01em;
10+
}
11+
12+
.md-sidebar--primary {
13+
display: none;
14+
}
Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
# ==============================================================================
16+
17+
######################################################################################################################
18+
# IMPORTANT: Files in legacy_tools are no longer used to generate the TensorFlow-Java API docs as there are unfixed issues
19+
# when using DocLava outside of the Google environment. We are keeping these for reference in case they are useful later.
20+
######################################################################################################################
21+
22+
1623
"""Generate TensorFlow Java reference docs for TensorFlow.org."""
1724
from __future__ import absolute_import
1825
from __future__ import division
@@ -21,6 +28,9 @@
2128
import pathlib
2229
import shutil
2330
import tempfile
31+
import io
32+
import requests
33+
import zipfile
2434
from git import Repo
2535

2636
from absl import app
@@ -29,14 +39,29 @@
2939
from tensorflow_docs.api_generator import gen_java
3040

3141
FLAGS = flags.FLAGS
42+
3243
NDARRAY_VERSION = 'v1.0.0'
44+
JAVACPP_VERSION = '1.5.11'
45+
PROTOBUF_VERSION = 'v3.21.9'
46+
47+
# __file__ is the path to this file
48+
TOOLS_DIR = pathlib.Path(__file__).resolve().parent
49+
DOCS_DIR = TOOLS_DIR.parent
50+
REPO_ROOT = DOCS_DIR.parent
51+
DOC_OUTPUT_DIR = DOCS_DIR.joinpath("output")
52+
53+
SECTION_LABELS = {
54+
'org.tensorflow': 'Core',
55+
'org.tensorflow.ndarray': 'NdArray',
56+
'org.tensorflow.framework': 'Framework',
57+
}
3358

3459
# These flags are required by infrastructure, not all of them are used.
35-
flags.DEFINE_string('output_dir', '/tmp/java_api/',
60+
flags.DEFINE_string('output_dir', f"{DOC_OUTPUT_DIR}",
3661
("Use this branch as the root version and don't"
3762
' create in version directory'))
3863

39-
flags.DEFINE_string('site_path', 'java/api_docs/java',
64+
flags.DEFINE_string('site_path', 'api_docs/',
4065
'Path prefix in the _toc.yaml')
4166

4267
flags.DEFINE_string('code_url_prefix', None,
@@ -46,20 +71,15 @@
4671
'search_hints', True,
4772
'[UNUSED] Include metadata search hints in the generated files')
4873

49-
# __file__ is the path to this file
50-
TOOLS_DIR = pathlib.Path(__file__).resolve().parent
51-
REPO_ROOT = TOOLS_DIR.parent
52-
5374

54-
def checkout_ndarray():
55-
repo_url = 'https://github.com/tensorflow/java-ndarray'
56-
local_repo_path = REPO_ROOT/'ndarray'
75+
def checkout_repo(repo_url: str, target_dir_name: str, version: str):
76+
local_repo_path = f"{REPO_ROOT}/{target_dir_name}"
5777
if not pathlib.Path(local_repo_path).exists():
5878
local_repo = Repo.clone_from(repo_url, local_repo_path)
5979
else:
6080
local_repo = Repo(local_repo_path)
6181
local_repo.remotes['origin'].fetch()
62-
local_repo.git.checkout(NDARRAY_VERSION)
82+
local_repo.git.checkout(version)
6383

6484

6585
def overlay(from_root, to_root):
@@ -74,25 +94,36 @@ def overlay(from_root, to_root):
7494

7595

7696
def main(unused_argv):
77-
checkout_ndarray()
97+
checkout_repo('https://github.com/tensorflow/java-ndarray', 'ndarray', NDARRAY_VERSION)
98+
checkout_repo('https://github.com/bytedeco/javacpp', 'javacpp', JAVACPP_VERSION)
99+
response = requests.get('https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.21.9/protobuf-java-3.21.9-sources.jar')
100+
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
101+
z.extractall(f"{REPO_ROOT}/protobuf")
102+
response = requests.get('https://repo1.maven.org/maven2/org/osgi/osgi.annotation/8.1.0/osgi.annotation-8.1.0-sources.jar')
103+
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
104+
z.extractall(f"{REPO_ROOT}/osgi")
105+
78106
merged_source = pathlib.Path(tempfile.mkdtemp())
79107
(merged_source / 'java/org').mkdir(parents=True)
80-
81108
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/', merged_source/'java/org/tensorflow')
82109
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow', merged_source/'java/org/tensorflow')
83-
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/proto', merged_source/'java/org/tensorflow/proto')
84-
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/main/java/org/tensorflow/exceptions', merged_source/'java/org/tensorflow/exceptions')
85-
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/internal/c_api', merged_source/'java/org/tensorflow/internal/c_api')
110+
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow', merged_source/'java/org/tensorflow')
111+
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/', merged_source/'java/org/tensorflow/')
112+
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/main/java/org/tensorflow/', merged_source/'java/org/tensorflow/')
86113
shutil.copytree(REPO_ROOT/'tensorflow-framework/src/main/java/org/tensorflow/framework', merged_source/'java/org/tensorflow/framework')
87114
shutil.copytree(REPO_ROOT/'ndarray/ndarray/src/main/java/org/tensorflow/ndarray', merged_source/'java/org/tensorflow/ndarray')
115+
shutil.copytree(REPO_ROOT/'javacpp/src/main/java/org/bytedeco', merged_source/'java/org/bytedeco')
116+
shutil.copytree(REPO_ROOT/'protobuf/com/', merged_source/'java/com')
117+
shutil.copytree(REPO_ROOT/'osgi/org/osgi', merged_source/'java/org/osgi')
88118

89119
gen_java.gen_java_docs(
90120
package='org.tensorflow',
91121
source_path=merged_source / 'java',
92122
output_dir=pathlib.Path(FLAGS.output_dir),
93123
site_path=pathlib.Path(FLAGS.site_path),
124+
section_labels=SECTION_LABELS,
94125
# Uncomment for local testing:
95-
# script_path=pathlib.Path(REPO_ROOT/'tools/run-javadoc-for-tf-local.sh'),
126+
script_path=pathlib.Path(TOOLS_DIR, 'run-javadoc-for-tf-local.sh'),
96127
)
97128

98129

docs/legacy_tools/requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
######################################################################################################################
2+
# IMPORTANT: Files in legacy_tools are no longer used to generate the TensorFlow-Java API docs as there are unfixed issues
3+
# when using DocLava outside of the Google environment. We are keeping these for reference in case they are useful later.
4+
######################################################################################################################
5+
6+
GitPython
7+
requests
8+
tensorflow-docs

tools/run-javadoc-for-tf-local.sh renamed to docs/legacy_tools/run-javadoc-for-tf-local.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/bash
2+
3+
######################################################################################################################
4+
# IMPORTANT: Files in legacy_tools are no longer used to generate the TensorFlow-Java API docs as there are unfixed issues
5+
# when using DocLava outside of the Google environment. We are keeping these for reference in case they are useful later.
6+
######################################################################################################################
7+
28
set -ex
39

410
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home # Or change to any JDK 11 home path
@@ -11,12 +17,13 @@ export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home # O
1117
# $ sudo apt install doclava-aosp #v 6.0.1+r55-1+build1
1218
#
1319
# https://unix.stackexchange.com/questions/594841/how-do-i-assign-a-value-to-a-bash-variable-iff-that-variable-is-null-unassigned
14-
DOCLAVA_JAR=${DOCLAVA_JAR:-'lib/doclava.jar'} # Build lib locally
20+
DOCLAVA_JAR=${DOCLAVA_JAR:-'tools/lib/doclava.jar'} # Build lib locally
21+
1522

1623
# Install java clear silver templates with:
1724
#
1825
# $ sudo apt install libjsilver-aosp-java #v 6.0.1+r55-1+build1
19-
JSILVER_JAR=${JSILVER_JAR:-'lib/jsilver.jar'} # Build lib locally
26+
JSILVER_JAR=${JSILVER_JAR:-'tools/lib/jsilver.jar'} # Build lib locally
2027

2128

2229
######### DELETE OUTPUT_DIR #################
@@ -56,16 +63,15 @@ for pkg in "${packages[@]}"; do
5663
SUBPACKAGES+=" -subpackages ${pkg}"
5764
done
5865
( # Capture the return code. it may be non-zero for minor errors.
59-
javadoc \
66+
/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/javadoc \
6067
-sourcepath "${SOURCE_PATH}" \
6168
-docletpath "${DOCLAVA_JAR}:${JSILVER_JAR}" \
6269
-doclet com.google.doclava.Doclava \
63-
-d "${OUTPUT_DIR}" \
6470
-toroot "${SITE_PATH}"/ \
6571
-yaml _toc.yaml \
6672
-templatedir "${TEMPLATES}" \
6773
-public \
68-
-devsite \
74+
-d "${OUTPUT_DIR}" \
6975
${FEDERATED_PARAMS} \
7076
${SUBPACKAGES}
7177
)

0 commit comments

Comments
 (0)