Skip to content

Commit e86c304

Browse files
authored
Touch up the documentation (#4245)
* docs: fix broken xrefs in quicktour and kotlin pages * docs: fix xref target from indexing to references in quicktour * docs: fix incorrect API usage in quicktour and updates examples * docs: fix textSearches examples - stale path, malformed save, removed execute() * docs: fix invalid AsciiDoc syntax - [WARN] admonition and Markdown fences * docs: fix typos and self-contradiction in configuration page * docs: complete references page - add MorphiaReference section and fix spacing * docs: add deprecation notice to updating-old and link from nav * docs: normalize all page titles to level-1 headings * docs: rename camelCase page files to kebab-case * docs: replace MapperOptions with MorphiaConfig and fix prose in mapping page * docs: update stale 2.x test file paths to 3.0 core/ layout * docs: use {srcRef} for test link in life-cycle-methods * docs: fix typos across sharding, schema-validation, life-cycle-methods, migrating, indexing, quicktour * docs: mark included files as page-partial, fix Update Operators caption * touch up the docs
1 parent e00f026 commit e86c304

23 files changed

Lines changed: 174 additions & 162 deletions

docs/modules/ROOT/nav.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* xref:index.adoc[Getting Started]
2-
** xref:migrating.adoc[Migrating]
32
** xref:quicktour.adoc[Quick Tour]
3+
** xref:migrating.adoc[Migrating]
4+
*** xref:updating-old.adoc[Legacy Update API (pre-3.0)]
45
56
* Features
67
** xref:configuration.adoc[Configuration]
@@ -13,11 +14,11 @@
1314
** xref:updates.adoc[Updating]
1415
** xref:deletes.adoc[Deleting]
1516
** xref:aggregations.adoc[Aggregation]
16-
** xref:textSearches.adoc[Text Search]
17+
** xref:text-searches.adoc[Text Search]
1718
** xref:references.adoc[References]
1819
** xref:transactions.adoc[Transactions]
19-
** xref:lifeCycleMethods.adoc[Life Cycle Methods]
20-
** xref:schemaValidation.adoc[Schema Validation]
20+
** xref:life-cycle-methods.adoc[Life Cycle Methods]
21+
** xref:schema-validation.adoc[Schema Validation]
2122
2223
* _Support_
2324
** xref:issues-help.adoc[Issues & Support]

docs/modules/ROOT/pages/aggregation-expressions.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:page-partial:
2+
13
[%header,cols="1,2,3"]
24
|===
35
|Operator|Docs|Test Examples

docs/modules/ROOT/pages/aggregation-stages.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:page-partial:
2+
13
[%header,cols="1,2,3"]
24
|===
35
|Operator|Docs|Test Examples

docs/modules/ROOT/pages/aggregations.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
== Aggregations
1+
= Aggregations
22

33
The {docsRef}/aggregation[aggregation framework] in MongoDB allows you to define a series (called a pipeline) of operations (called stages) against the data in a collection.
44
These pipelines can be used for analytics or they can be used to convert your data from one form to another.
55
This guide will not go in to the details of how aggregation works, however.
66
The official MongoDB {docsRef}/aggregation[documentation] has extensive tutorials on such details.
77
Rather, this guide will focus on the Morphia API. The examples shown here are taken from the
8-
{srcRef}/morphia/src/test/java/dev/morphia/aggregation/AggregationTest.java[tests] in Morphia itself. You can find the full list in the <<Supported Operators>> section.
8+
{srcRef}/core/src/test/java/dev/morphia/aggregation/AggregationTest.java[tests] in Morphia itself. You can find the full list in the <<Supported Operators>> section.
99

1010
Writing an aggregation pipeline starts just like writing a standard query.
1111
As with querying, we start with the `Datastore`:
@@ -17,7 +17,7 @@ include::example$TestDocsExamples.java[tag=basic]
1717

1818
`aggregate()` takes a `Class` literal. This lets Morphia know which collection to perform this aggregation against. Because of the transformational operations available in the aggregation {docsRef}/core/aggregation-pipeline[pipeline], Morphia can not validate as much as it can with querying so care will need to be taken to ensure document fields actually exist when referencing them in your pipeline.
1919

20-
=== The Pipeline
20+
== The Pipeline
2121

2222
Aggregation pipelines are comprised of a series stages.
2323
Our example here with the `group()` stage. This method is the Morphia equivalent of the
@@ -34,7 +34,7 @@ the Morphia equivalent of an {docsRef}/reference/operator/aggregation/group/#gro
3434
{ "_id" : "Dante", "books" : [ "The Banquet", "Divine Comedy", "Eclogues" ] }
3535
----
3636

37-
=== Executing the Pipeline
37+
== Executing the Pipeline
3838

3939
Once your pipeline is complete, you can execute it via the `execute()` method.
4040
This method optionally takes a `Class` reference for the target type of your aggregation.
@@ -43,7 +43,7 @@ Additionally, you can also include some options to `execute()`.
4343
We can use the various options on the
4444
link:javadoc/dev/morphia/aggregation/AggregationOptions.html[AggregationOptions] class to configure how we want the pipeline to execute.
4545

46-
==== $out
46+
== $out
4747

4848
Depending your use case, you might not want to return the results of your aggregation but simply output them to another collection.
4949
That's where `$out` comes in. {docsRef}/reference/operator/aggregation/out/[$out] is an operator that allows the results of a pipeline to be stored in to a named collection.
@@ -66,7 +66,7 @@ that reflects the collection we want to write our output to. Morphia will use t
6666
your entities to determine that collection name. You may also pass a String with the collection name as well if the target collection
6767
does not correspond to a mapped entity.
6868

69-
==== $merge
69+
== $merge
7070

7171
{docsRef}/reference/operator/aggregation/merge/[$merge] is a very similar option with a some major differences.
7272
The biggest difference is that `$merge` can write to existing collections without destroying the existing documents. `$out` would
@@ -86,7 +86,7 @@ Because there may be existing data in the collection, we need to instruct the op
8686
In this example, when documents matching we're choosing to replace them and when they don't we're instructing the operation to insert the
8787
new documents in to the collection. Other options are defined on `com.mongodb.client.model.MergeOptions` type defined by the Java driver.
8888

89-
=== Supported Operators
89+
== Supported Operators
9090
Every effort is made to provide 100% coverage of all the operators offered by MongoDB. A select handful of operators have been excluded
9191
for reasons of suitability in Morphia. In short, some operators just don't make sense in Morphia. Below is listed all the currently
9292
supported operators. To see an example of an operator in action, click through to see the test cases for that operator.

docs/modules/ROOT/pages/configuration.adoc

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
== Configuration
1+
= Configuration
22

3-
Starting in Morphia 3.0, configuration will be driven via a configuration file. However programmatic configuration is still supportedfor those who prefer, or need, a more flexible approach. The file should live in your build's resources folder and be named `META-INF/morphia-config.properties`. Reference documentation for the configuration file can be found in the link:++javadoc/dev/morphia/config/MorphiaConfig.html++[javadoc] but
3+
Starting in Morphia 3.0, configuration will be driven via a configuration file. However programmatic configuration is still supported for those who prefer, or need, a more flexible approach. The file should live in your build's resources folder and be named `META-INF/morphia-config.properties`. Reference documentation for the configuration file can be found in the link:++javadoc/dev/morphia/config/MorphiaConfig.html++[javadoc] but
44
we'll go in depth on a few items here. An example configuration file is included below. All possible configuration elements are listed. However, if the default values are acceptable that element can be safely omitted from your file.
55

66
`Morphia.createDatastore()` can be called link:++javadoc/dev/morphia/Morphia.html#createDatastore(com.mongodb.client.MongoClient,dev.morphia.config.MorphiaConfig)++[with]
77
and link:++javadoc/dev/morphia/Morphia.html#createDatastore(com.mongodb.client.MongoClient)++[without] an explicit `MorphiaConfig`
8-
argument. When not explicitly given a `MorphiaConfig`, Morphia will attempt to load the configuration file at the location show above.
8+
argument. When not explicitly given a `MorphiaConfig`, Morphia will attempt to load the configuration file at the location shown above.
99
Failing to find a configuration file, it will create a new configuration using the default values which can be found in the javadoc.
1010
These values are unlikely to be suitable long term but should be sufficient for newcomers looking to test things out a little before
1111
committing to adopt Morphia.
1212

13-
=== Manually loading configurations
13+
== Manually loading configurations
1414
In some cases, you might find the need for multiple configuration files. Such scenarios include varying test
1515
environments/configurations, multiple dataset configurations, or externally supplied configurations. In such cases, you can manually
1616
load those configurations using link:++javadoc/dev/morphia/config/MorphiaConfig.html#load(java.lang.String)++[MorphiaConfig.load()]. You
1717
can then pass this instance to `createDatastore()`.
1818

19-
=== Dynamic configuration creation
19+
== Dynamic configuration creation
2020
For many, the ability to dynamically create `MorphiaConfig` instances is not just a nicety but a hard requirement. In this case, there
2121
are methods on `MorphiaConfig` to return a new version of the configuration with the updated value. `MorphiaConfig` is immutable,
2222
however, so be sure to use the returned reference and not the original. It should also be noted that once a `Datastore` is created using
2323
a `MorphiaConfig`, that configuration is fixed and can not be changed. A new `Datastore` would need to be created with the updated version.
2424

25-
=== Collection and property naming
25+
== Collection and property naming
2626

2727
* `morphia.collection-naming`
2828
* `morphia.property-naming`
@@ -50,7 +50,7 @@ For the provided strategies, you can simply use the shortened version as shown i
5050
can enable it by giving the fully qualified classname (fqcn) instead. The same applies everywhere you see `fqcn` in the sample file.
5151
====
5252

53-
=== Discriminator keys and values
53+
== Discriminator keys and values
5454

5555
* `morphia.discriminator`
5656
* `morphia.discriminator-key`
@@ -66,18 +66,19 @@ The choices here are simpler:
6666
1. `className()`/`lowerClassName()`
6767
2. `simpleName()`/`lowerSimpleName()`
6868

69-
Simple name is the fully qualified classname without the package name. These can all be accessed via their named methods on
69+
Simple name is the class name without the package name. These can all be accessed via their named methods on
7070
link:++javadoc/dev/morphia/mapping/DiscriminatorFunction.html++[DiscriminatorFunction] and just like the `NamingStrategy` cases, if the
7171
provided options are not sufficient, you can implement your own by subclassing `DiscriminatorFunction` and implementing your own function.
7272

73-
=== Mapper selection
73+
== Mapper selection
7474

7575
* `morphia.mapper`
7676

7777
Morphia supports two mapper implementations, selectable via configuration:
7878

7979
1. `reflection` *(default)* — the traditional reflection-based mapper. No additional dependencies required.
80-
2. `critter` — a bytecode-generation mapper that produces `VarHandle`-based accessors at runtime via Gizmo, with automatic fallback to reflection if generation fails for a given type. Pre-generated models from the `critter-maven` plugin are used when available (AOT path), otherwise models are generated at JVM startup.
80+
2. `critter` — a bytecode-generation mapper that produces bytecode to handle serialization rather than using reflection.
81+
This option should give you better performance overall. Pre-generated models from the `critter-maven` plugin are used when available (AOT path), otherwise models are generated at JVM startup.
8182

8283
To enable the critter mapper, add the following to your `META-INF/morphia-config.properties`:
8384

@@ -90,7 +91,7 @@ Or pass `-Dmorphia.mapper=critter` on the Maven command line when running tests.
9091

9192
For production deployments, consider using the xref:maven-plugin.adoc[critter-maven plugin] to generate models at build time and eliminate the startup cost entirely.
9293

93-
=== User-defined Codecs
94+
== User-defined Codecs
9495

9596
* `morphia.codec-provider`
9697

@@ -114,13 +115,13 @@ will not only make it consistent with other configurable elements but will make
114115
the note below about using the ServiceLoader with Java 9 modules.
115116
====
116117

117-
==== Property Codecs
118+
== Property Codecs
118119
As unusual as is the need for a custom codec to handle types, there are rare cases where how Morphia processes a property on entity needs
119120
to be customized. This processing is handled via the
120121
link:++javadoc/dev/morphia/mapping/codec/MorphiaPropertyCodecProvider.html++[MorphiaPropertyCodecProvider]. Morphia discovers these
121122
custom implementations via SPI the details of which won't be covered here.
122123

123-
=== Legacy Configuration
124+
== Legacy Configuration
124125

125126
Morphia can be configured in one of two ways: the legacy mode and the modern mode. The defaults in the configuration code will give you
126127
the modern configuration and is the recommended way to configure Morphia. However, if you're upgrading an older project, you very likely
@@ -131,16 +132,14 @@ Using the legacy configuration is a matter of defining a few entries in your con
131132
you already have a `MorphiaConfig` in hand but would like to update it to reflect the legacy style configuration, you can call `.legacy()`
132133
on that reference and use the resulting `MorphiaConfig` instance.
133134

134-
=== Sample config files
135+
== Sample config files
135136

136137
.Complete with defaults
137138
[,txt]
138139
----
139140
include::example$complete-morphia-config.properties[]
140141
----
141142

142-
---
143-
144143
.Minimal config file
145144
[,txt]
146145
----
@@ -149,32 +148,31 @@ include::example$minimal-morphia-config.properties[]
149148

150149
[NOTE]
151150
====
152-
The minimum config is, indeed, an empty (or even nonexistant) file as there are defaults for each value. This is intended to "pave the
151+
The minimum config is, indeed, an empty (or even nonexistent) file as there are defaults for each value. This is intended to "pave the
153152
on ramp" for those new to Morphia. It is expected that some of those values, notably the database and packages fields, will eventually
154153
be updated with more suitable values.
155154
====
156-
---
157155

158156
.Legacy config file
159157
[,txt]
160158
----
161159
include::example$legacy-morphia-config.properties[]
162160
----
163161

164-
[WARN]
162+
[WARNING]
165163
====
166-
The legacy query factory is deprecated and will be removed in 3.0. It is advisable to switch to the newer query filters based API now to
167-
avoid breakage.
164+
The legacy query factory has been removed in 3.0. Switch to the newer query filters based API.
168165
====
169166

170-
=== Some notes on ServiceLoader
167+
== Some notes on ServiceLoader
171168

172169
Morphia provides a number of extensibility points using https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html[the SPI mechanism]
173170
available in the JVM. This allows for seamless, config-free inclusion of different functionality. In general, this works without notice
174171
because most users will not need to implement such features and so needn't be bothered with such details. However, if you are one of the
175172
lucky ones that *does* need to know *and* you use Java modules, please be aware that the usual services file in `META-INF/services` won't
176173
work. In order to export your service for Morphia to find you need an entry in your `module-info.java` file as shown below:
177174

178-
```java
175+
[source,java]
176+
----
179177
provides dev.morphia.mapping.codec.MorphiaPropertyCodecProvider with com.foo.MyCodecProvider;
180-
```
178+
----

docs/modules/ROOT/pages/deletes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
== Deletes
1+
= Deletes
22

33
Queries are used to delete documents from the database as well.
44
Using

docs/modules/ROOT/pages/indexing.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
== Indexing
1+
= Indexing
22

33
Morphia provides annotations that allow developers to define indexes for a collection to be defined alongside the other mapping data on an entity's source.
44
In addition to the familiar ascending/descending index types, Morphia and MongoDB support
@@ -10,7 +10,7 @@ setting the `morphia.apply-indexes` to true in the xref:configuration.adoc[confi
1010

1111
There are two ways to define indexes: at the class level and at the field level.
1212

13-
=== Class Level Indexes
13+
== Class Level Indexes
1414

1515
Class level indexing begins with the link:javadoc/dev/morphia/annotations/Indexes.html[@Indexes] annotation.
1616
This is a container annotation whose sole purpose is to hold a number of link:javadoc/dev/morphia/annotations/Index.html[@Index] annotations.
@@ -38,7 +38,7 @@ public class IndexExample {
3838
}
3939
----
4040

41-
=== Fields
41+
== Fields
4242

4343
Which fields to index are defined with the link:javadoc/dev/morphia/annotations/Field.html[@Field] annotation.
4444
An arbitrary number of link:javadoc/dev/morphia/annotations/Field.html[@Field]s can be given but at least one must be present.
@@ -48,23 +48,23 @@ annotations.
4848
For most index types, this value is validated by default.
4949
An exception is made for <<_text_indexing,text indexing>> as discussed below.
5050

51-
=== Index Options
51+
== Index Options
5252

5353
Options for an index are defined on the link:javadoc/dev/morphia/annotations/IndexOptions.html[@IndexOptions].
54-
More complete documenation can be found in the {docsRef}/reference/method/db.collection.createIndex/#options[manual].
54+
More complete documentation can be found in the {docsRef}/reference/method/db.collection.createIndex/#options[manual].
5555
Using the options allows you to run indexing in the background, e.g. By default, creating an index blocks all other operations on a database.
5656
When building an index on a collection, the database that holds the collection is unavailable for read or write operations until the index build completes.
5757
For potentially long running index building operations, consider the **background** operation so that the MongoDB database remains available during the index building operation.
5858
The MongoDB {docsRef}/core/index-creation/#background-construction[manual] has more detail.
5959

60-
By default Morphia will attempt to validate the fields specified but in some cases that isn't desirable so you can turn it off via the options refernce. `IndexOptions` lets you define {docsRef}/core/index-ttl/[TTL], {docsRef}/core/index-sparse/[sparse], and {docsRef}/core/index-partial/[partial] indexes as well. `IndexOptions` can also be used to give an index a more human friendly name.
60+
By default Morphia will attempt to validate the fields specified but in some cases that isn't desirable so you can turn it off via the options reference. `IndexOptions` lets you define {docsRef}/core/index-ttl/[TTL], {docsRef}/core/index-sparse/[sparse], and {docsRef}/core/index-partial/[partial] indexes as well. `IndexOptions` can also be used to give an index a more human friendly name.
6161

6262
[NOTE]
6363
====
6464
Whether user specified or MongoDB generated, index names including their full namespace (i.e. database.collection) cannot be longer than the {docsRef}/reference/limits/#Index-Name-Length[Index Name Limit].
6565
====
6666

67-
==== Partial Indexes
67+
== Partial Indexes
6868

6969
New in MongoDB 3.2, https://docs.mongodb.com/v3.2/core/index-partial/[partial indexes] only index the documents in a collection that meet a specified filter expression thereby reducing storage and maintenance costs.
7070
A partial filter is defined using a query as shown here:
@@ -122,7 +122,7 @@ A wild card text index declaration would look like this:
122122
A collection can have at most one text index.
123123
====
124124

125-
=== Collation
125+
== Collation
126126

127127
Collation allows users to specify language-specific rules for string comparison such as rules for lettercase and accent marks.
128128
A collation can be defined using the `collation()` property on link:javadoc/dev/morphia/annotations/IndexOptions.html[@IndexOptions]

docs/modules/ROOT/pages/kotlin.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
== Kotlin
1+
= Kotlin
22

33
In general, your Kotlin types should work out of the box with Morphia.
44
There are, however, a few interesting cases where they need a little extra help.
@@ -35,4 +35,4 @@ This module should support any
3535
`ReadWriteProperty` type but is only currently tested against the `notNull()` case.
3636

3737
All that is needed to enable this more targeted support is to simply add the new dependency to your project as shown above and it should magically "Just Work&#8482;".
38-
If you find something that doesn't work in your Kotlin project, please file an xref:/issues-help.adoc[issue].
38+
If you find something that doesn't work in your Kotlin project, please file an xref:issues-help.adoc[issue].

0 commit comments

Comments
 (0)