|
1 |
| -# SciJava Discovery: A library for the abstraction of service discovery mechanisms |
| 1 | +# SciJava Discovery Therapi: A Discoverer implementation backed by Therapi |
2 | 2 |
|
3 |
| -This module provides the `Discoverer` interface, an abstraction for service discovery. |
| 3 | +This module provides the `TherapiDiscover`, a `Discoverer` implementation that uses [`therapi-runtime-javadoc`](https://github.com/dnault/therapi-runtime-javadoc) to discover tagged elements through javadoc tags. |
| 4 | + |
| 5 | +`TherapiDiscoverer` **only** implements `Discoverer.elementsTaggedWith(String tag)`. |
| 6 | + |
| 7 | +To make tags discoverable via `TherapiDiscoverer`, one must first enable therapi's annotation processor. |
| 8 | + |
| 9 | +```java |
| 10 | +<properties> |
| 11 | + <therapi.version>0.12.0</therapi.version> |
| 12 | + <therapi-runtime-javadoc-scribe.version>${therapi.version}</therapi-runtime-javadoc-scribe.version> |
| 13 | + <therapi.packages></therapi.packages> |
| 14 | +</properties> |
| 15 | +``` |
| 16 | + |
| 17 | +This sets the therapi version, and denotes the packages (using the `<therapi.packages>` tag) that should be processed. This can be left blank to indicate all packages, or can be a comma-delimited list to process **only** those packages. |
| 18 | + |
| 19 | +```java |
| 20 | +<build> |
| 21 | + <plugins> |
| 22 | + <plugin> |
| 23 | + <artifactId>maven-compiler-plugin</artifactId> |
| 24 | + <configuration> |
| 25 | + <annotationProcessorPaths> |
| 26 | + <path> |
| 27 | + <groupId>com.github.therapi</groupId> |
| 28 | + <artifactId>therapi-runtime-javadoc-scribe</artifactId> |
| 29 | + <version>${therapi-runtime-javadoc-scribe.version}</version> |
| 30 | + </path> |
| 31 | + </annotationProcessorPaths> |
| 32 | + <fork>true</fork> |
| 33 | + <compilerArgs> |
| 34 | + <arg>-Ajavadoc.packages="${therapi.packages}"</arg> |
| 35 | + </compilerArgs> |
| 36 | + </configuration> |
| 37 | + </plugin> |
| 38 | + </plugins> |
| 39 | +</build> |
| 40 | +``` |
| 41 | + |
| 42 | +These elements already live in `scijava-incubator`, and will be moved upstream to `pom-scijava` at a later date. This means that all incubator projects (and later all SciJava projects) will have therapi capabilities for free. This behavior is **opt-in**; to enable therapi's annotation processor (and thus any functionality from `TherapiDiscoverer`) one must add `<therapi.packages></therapi.packages>` to the `properties` section of their POM. |
| 43 | + |
| 44 | +## Tag Structure |
| 45 | + |
| 46 | +To add a tag to any [`AnnotatedElement`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/AnnotatedElement.html), one can simply insert the [`@implNote`](https://nipafx.dev/javadoc-tags-apiNote-implSpec-implNote/) tag into the javadoc of that `AnnotatedElement`. Tags should be structured as |
| 47 | + |
| 48 | +```java |
| 49 | +@implNote <tagType> <tagBody> |
| 50 | +``` |
| 51 | + |
| 52 | +Where `tagType` is the `String` under which this `AnnotatedElement` should be discovered, and `tagBody` is any set of options relevant for the `tagType`. **TODO: `tagBody` structure** |
| 53 | + |
| 54 | +An example might look like |
| 55 | + |
| 56 | +```java |
| 57 | + |
| 58 | +/** |
| 59 | + * @implNote foo |
| 60 | + */ |
| 61 | +public void taggedMethod(...) { |
| 62 | + ... |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +Assuming therapi processes the package containing `taggedMethod`, `taggedMethod` can then be retrieved using `TherapiDiscoverer.elementsTaggedWith("foo")`. |
4 | 67 |
|
5 |
| -WIP |
|
0 commit comments