Skip to content

Commit 4e93883

Browse files
authored
MONGOID-5521 migrate Mongoid docs to snooty (#5513)
* fix code blocks * MONGOID-5521 fix all parse errors * build docs with github action * Revert "build docs with github action" This reverts commit 9ffda4493f774843f360517e27538ede6dd9020f.
1 parent 8c58d45 commit 4e93883

File tree

9 files changed

+75
-86
lines changed

9 files changed

+75
-86
lines changed

source/reference/associations.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ help of MongoDB projection operation:
592592
Band.where(started_on: {'$gt' => Time.now - 1.year}).only(:label).map(&:label).compact.uniq
593593

594594
Setting Stale Values on Referenced Associations
595-
``````````````````````````````````````````````
595+
```````````````````````````````````````````````
596596

597597
Setting a stale value to a referenced association can sometimes result in
598598
a ``nil`` value being persisted to the database. Take the following case:
@@ -744,14 +744,14 @@ The following deviations are known:
744744

745745
As of this writing, the known cases of such deviation are:
746746

747-
- 3.2 and earlier servers not validating ``$size`` arguments as strictly as newer versions do.
748-
- 4.0 and earlier servers not validating ``$type`` arguments as strictly as newer versions
749-
do (allowing invalid arguments like 0, for example).
750-
- 3.2 and earlier servers not supporting ``Decimal128`` for ``$type``, as well as allowing invalid
751-
arguments such as negative numbers (smaller than -1) and numbers that are greater than 19
752-
(not including 127, the argument for the ``MaxKey`` type).
753-
- 3.4 and earlier servers not supporting arrays for ``$type``.
754-
- 3.0 and earlier servers not supporting bitwise operators.
747+
- 3.2 and earlier servers not validating ``$size`` arguments as strictly as newer versions do.
748+
- 4.0 and earlier servers not validating ``$type`` arguments as strictly as newer versions
749+
do (allowing invalid arguments like 0, for example).
750+
- 3.2 and earlier servers not supporting ``Decimal128`` for ``$type``, as well as allowing invalid
751+
arguments such as negative numbers (smaller than -1) and numbers that are greater than 19
752+
(not including 127, the argument for the ``MaxKey`` type).
753+
- 3.4 and earlier servers not supporting arrays for ``$type``.
754+
- 3.0 and earlier servers not supporting bitwise operators.
755755

756756

757757
- Mongoid DSL expands ``Range`` arguments to hashes with ``$gte`` and ``$lte``

source/reference/configuration.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ use an initializer as follows:
656656
same instance as the Rails logger, modifying any of the instances affects
657657
all of them. For example the following changes log level for all three
658658
loggers, unless the application assigned a separate ``Logger`` instance
659-
to `Mongo::Logger.logger`` as described above:
659+
to ``Mongo::Logger.logger`` as described above:
660660

661661
.. code-block:: ruby
662662

@@ -839,7 +839,7 @@ Every ``Proc`` in ``Mongo.tls_context_hooks`` will be passed an
839839
``OpenSSL::SSL::SSLContext`` object as its sole argument. These procs will
840840
be executed sequentially during socket creation.
841841

842-
..warning ::
842+
.. warning::
843843

844844
TLS context hooks are global and will affect all ``Mongo::Client`` instances
845845
in an application.
@@ -985,8 +985,8 @@ Query Cache Middleware
985985
.. note::
986986

987987
When used with Ruby driver version 2.15 or newer, Mongoid's Query Cache
988-
Middleware delegates to :ref:`the driver's Query Cache Middleware
989-
<driver:query-cache-middleware>`.
988+
Middleware delegates to `the driver's Query Cache Middleware
989+
<https://www.mongodb.com/docs/ruby-driver/current/reference/query-cache/index.html#query-cache-middleware>`_.
990990

991991
Mongoid provides a Rack middleware which enables the :ref:`Query Cache
992992
<query-cache>` for the duration of each web request. Below is an example of

source/reference/fields.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Field Types
2121
MongoDB stores underlying document data using
2222
`BSON types <https://mongodb.com/docs/manual/reference/bson-types/>`_, and
2323
Mongoid converts BSON types to Ruby types at runtime in your application.
24-
For example, a field defined with `type: :float` will use the Ruby ``Float``
24+
For example, a field defined with ``type: :float`` will use the Ruby ``Float``
2525
class in-memory and will persist in the database as the the BSON ``double`` type.
2626

2727
Field type definitions determine how Mongoid behaves when constructing queries
@@ -217,9 +217,9 @@ and has the same behavior in all circumstances.
217217

218218
Mongoid also provides the deprecated ``Symbol`` field type for serializing
219219
Ruby symbols to BSON symbols. Because the BSON specification deprecated the
220-
BSON symbol type, the `bson` gem will serialize Ruby symbols into BSON strings
220+
BSON symbol type, the ``bson`` gem will serialize Ruby symbols into BSON strings
221221
when used on its own. However, in order to maintain backwards compatibility
222-
with older datasets, the `mongo` gem overrides this behavior to serialize Ruby
222+
with older datasets, the ``mongo`` gem overrides this behavior to serialize Ruby
223223
symbols as BSON symbols. This is necessary to be able to specify queries for
224224
documents which contain BSON symbols as fields.
225225

source/reference/queries.txt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ and :ref:`field aliases <field-aliases>`:
233233
# class: Band
234234
# embedded: false>
235235

236-
Since `id` and `_id` fields are aliases, either one can be used for queries:
236+
Since ``id`` and ``_id`` fields are aliases, either one can be used for queries:
237237

238238
.. code-block:: ruby
239239

@@ -1722,43 +1722,43 @@ For example, consider the following model definition that contains a ``Time``
17221722
field, a ``Date`` field and an implicit ``Object`` field, and also
17231723
intentionally does not define a field called ``deregistered_at``:
17241724

1725-
.. code-block:: ruby
1725+
.. code-block:: ruby
17261726

1727-
class Voter
1728-
include Mongoid::Document
1727+
class Voter
1728+
include Mongoid::Document
17291729

1730-
field :born_on, type: Date
1731-
field :registered_at, type: Time
1732-
field :voted_at
1733-
end
1730+
field :born_on, type: Date
1731+
field :registered_at, type: Time
1732+
field :voted_at
1733+
end
17341734

17351735
Queries on ``born_on`` and ``registered_at`` fields using ``Date`` and ``Time``
17361736
values, respectively, are straightforward:
17371737

1738-
.. code-block:: ruby
1738+
.. code-block:: ruby
17391739

1740-
Voter.where(born_on: Date.today).selector
1741-
# => {"born_on"=>2020-12-18 00:00:00 UTC}
1740+
Voter.where(born_on: Date.today).selector
1741+
# => {"born_on"=>2020-12-18 00:00:00 UTC}
17421742

1743-
Voter.where(registered_at: Time.now).selector
1744-
# => {"registered_at"=>2020-12-19 04:33:36.939788067 UTC}
1743+
Voter.where(registered_at: Time.now).selector
1744+
# => {"registered_at"=>2020-12-19 04:33:36.939788067 UTC}
17451745

17461746
But, note the differences in behavior when providing a ``Date`` instance
17471747
in all possible scenarios:
17481748

1749-
.. code-block:: ruby
1749+
.. code-block:: ruby
17501750

1751-
Voter.where(born_on: Date.today).selector
1752-
# => {"born_on"=>2020-12-18 00:00:00 UTC}
1751+
Voter.where(born_on: Date.today).selector
1752+
# => {"born_on"=>2020-12-18 00:00:00 UTC}
17531753

1754-
Voter.where(registered_at: Date.today).selector
1755-
# => {"registered_at"=>2020-12-18 00:00:00 -0500}
1754+
Voter.where(registered_at: Date.today).selector
1755+
# => {"registered_at"=>2020-12-18 00:00:00 -0500}
17561756

1757-
Voter.where(voted_at: Date.today).selector
1758-
# => {"voted_at"=>Fri, 18 Dec 2020}
1757+
Voter.where(voted_at: Date.today).selector
1758+
# => {"voted_at"=>Fri, 18 Dec 2020}
17591759

1760-
Voter.where(deregistered_at: Date.today).selector
1761-
# => {"deregistered_at"=>2020-12-18 00:00:00 UTC}
1760+
Voter.where(deregistered_at: Date.today).selector
1761+
# => {"deregistered_at"=>2020-12-18 00:00:00 UTC}
17621762

17631763
When using the ``registered_at`` field which is of type ``Time``, the date
17641764
was interpreted to be in local time (as per the :ref:`configured time zone
@@ -2476,7 +2476,7 @@ on when the query results are being accessed:
24762476
Even though ``load_async`` method returns a ``Criteria`` object, you should not
24772477
do any operations on this object except accessing query results. The query is
24782478
scheduled for execution immediately after calling ``load_async``, therefore
2479-
later changes to the `Criteria`` object may not be applied.
2479+
later changes to the ``Criteria`` object may not be applied.
24802480

24812481

24822482
Configuring asynchronous query execution

source/reference/rails-integration.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Controller Runtime Instrumentation
6161

6262
Mongoid provides time spent executing MongoDB commands (obtained via a
6363
driver command monitoring subscription) to Rails' instrumentation event
64-
`process_action.action_controller`. This time is logged together with view
64+
``process_action.action_controller``. This time is logged together with view
6565
time like so:
6666

6767
.. code-block:: none

source/release-notes/mongoid-7.2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ instead of loading the entire association.
260260
``StringifiedSymbol`` Field Type
261261
--------------------------------
262262

263-
New feature: the :ref:`StringifiedSymbol field type <stringified-symbol>`
263+
New feature: the :ref:`StringifiedSymbol field type <field-type-stringified-symbol>`
264264
was added for storing Ruby symbol values in MongoDB in a manner interoperable
265265
with other programming languages.
266266

@@ -414,7 +414,7 @@ of the legacy query cache, see :ref:`the query cache documentation <query-cache>
414414
Minor change: when a ``String`` value is written in a ``Regexp`` field,
415415
Mongoid 7.2 stores that value in MongoDB as a regular expression.
416416
Subsequently it would be retrieved :ref:`as a BSON::Regexp::Raw instance
417-
<regular-expression-fields>`.
417+
<field-type-regexp>`.
418418
Previously the value would be stored as a string and would be retrieved as
419419
a string.
420420

source/release-notes/mongoid-8.0.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@ Changes to the ``attributes_before_type_cast`` Hash
152152
The ``attributes_before_type_cast`` hash has been changed to function more like
153153
ActiveRecord:
154154

155-
- On instantiation of a new model (without parameters), the
156-
``attributes_before_type_cast`` hash has the same contents as the
157-
``attributes`` hash. If parameters are passed to the initializer, those
158-
values will be stored in the ``attributes_before_type_cast`` hash before
159-
they are ``mongoized``.
160-
- When assigning a value to the model, the ``mongoized`` value (i.e. when
161-
assiging '1' to an Integer field, it is ``mongoized`` to 1) is stored in
162-
the ``attributes`` hash, whereas the raw value (i.e. '1') is stored in the
163-
``attributes_before_type_cast`` hash.
164-
- When saving, creating (i.e. using the ``create!`` method), or reloading the
165-
model, the ``attributes_before_type_cast`` hash is reset to have the same
166-
contents as the ``attributes`` hash.
167-
- When reading a document from the database, the ``attributes_before_type_cast``
168-
hash contains the attributes as they appear in the database, as opposed to
169-
their ``demongoized`` form.
155+
- On instantiation of a new model (without parameters), the
156+
``attributes_before_type_cast`` hash has the same contents as the
157+
``attributes`` hash. If parameters are passed to the initializer, those
158+
values will be stored in the ``attributes_before_type_cast`` hash before
159+
they are ``mongoized``.
160+
- When assigning a value to the model, the ``mongoized`` value (i.e. when
161+
assiging '1' to an Integer field, it is ``mongoized`` to 1) is stored in
162+
the ``attributes`` hash, whereas the raw value (i.e. '1') is stored in the
163+
``attributes_before_type_cast`` hash.
164+
- When saving, creating (i.e. using the ``create!`` method), or reloading the
165+
model, the ``attributes_before_type_cast`` hash is reset to have the same
166+
contents as the ``attributes`` hash.
167+
- When reading a document from the database, the ``attributes_before_type_cast``
168+
hash contains the attributes as they appear in the database, as opposed to
169+
their ``demongoized`` form.
170170

171171

172172
Order of Callback Invocation

source/tutorials/getting-started-rails6.txt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Add Mongoid
105105
`mongoid <https://rubygems.org/gems/mongoid/>`_ gem:
106106

107107
.. code-block:: ruby
108-
:name: Gemfile
109108
:caption: Gemfile
110109

111110
gem 'mongoid', '~> 7.0.5'
@@ -132,6 +131,8 @@ Note that as we are not using ActiveRecord we will not have a ``database.yml``
132131
file.
133132

134133

134+
.. _run-locally:
135+
135136
Run MongoDB Locally
136137
-------------------
137138

@@ -157,6 +158,8 @@ like this:
157158
server_selection_timeout: 1
158159

159160

161+
.. _use-atlas:
162+
160163
Use MongoDB Atlas
161164
-----------------
162165

@@ -247,7 +250,6 @@ Open the ``Post`` model file, ``app/models/post.rb``, and add a ``has_many``
247250
association for the comments:
248251

249252
.. code-block:: ruby
250-
:name: app/models/post.rb
251253
:caption: app/models/post.rb
252254

253255
class Post
@@ -267,7 +269,6 @@ association for the comments:
267269
generated ``embedded_in`` association to ``belongs_to``:
268270

269271
.. code-block:: ruby
270-
:name: app/models/comment.rb
271272
:caption: app/models/comment.rb
272273

273274
class Comment
@@ -283,7 +284,6 @@ Open the post show view file, ``app/views/posts/show.html.erb``, and add
283284
a section rendering existing comments and prompting to leave a new comment:
284285

285286
.. code-block:: html
286-
:name: app/views/posts/show.html.erb
287287
:caption: app/views/posts/show.html.erb
288288

289289
<section class="section comments">
@@ -306,7 +306,6 @@ from ``text_field`` to ``text_area``, as well as the type of field for
306306
should look like this:
307307

308308
.. code-block:: html
309-
:name: app/views/comments/_form.html.erb
310309
:caption: app/views/comments/_form.html.erb
311310

312311
<%= form_with(model: comment, local: true) do |form| %>
@@ -345,7 +344,6 @@ Create a partial for the comment view, ``app/views/comments/_comment.html.erb``
345344
with the following contents:
346345

347346
.. code-block:: html
348-
:name: app/views/comments/_comment.html.erb
349347
:caption: app/views/comments/_comment.html.erb
350348

351349
<p>
@@ -377,7 +375,6 @@ Remove or comment out any RDBMS libraries like ``sqlite``, ``pg`` etc.
377375
mentioned in ``Gemfile``, and add ``mongoid``:
378376

379377
.. code-block:: ruby
380-
:name: Gemfile
381378
:caption: Gemfile
382379

383380
gem 'mongoid', '~> 7.0.5'
@@ -399,7 +396,6 @@ Examine ``config/application.rb``. If it is requiring all components of Rails
399396
via ``require 'rails/all'``, change it to require individual frameworks:
400397

401398
.. code-block:: ruby
402-
:name: config/application.rb
403399
:caption: config/application.rb
404400

405401
# Remove or comment out
@@ -472,9 +468,9 @@ Generate the default Mongoid configuration:
472468
This generator will create the ``config/mongoid.yml`` configuration file,
473469
which is used to configure the connection to the MongoDB deployment.
474470

475-
Review the sections `Run MongoDB Locally`_ and `Use MongoDB Atlas`_
476-
to decide how you would like to deploy MongoDB, and adjust Mongoid
477-
configuration (``config/mongoid.yml``) to match.
471+
Review the sections :ref:`Run MongoDB Locally <run-locally>` and
472+
:ref:`Use MongoDB Atlas <use-atlas>` to decide how you would like to deploy
473+
MongoDB, and adjust Mongoid configuration (``config/mongoid.yml``) to match.
478474

479475
Adjust Models
480476
-------------
@@ -491,7 +487,6 @@ explicit field definitions).
491487
For example, a bare-bones Post model may look like this in ActiveRecord:
492488

493489
.. code-block:: ruby
494-
:name: app/models/post.rb
495490
:caption: app/models/post.rb
496491

497492
class Post < ApplicationRecord
@@ -501,7 +496,6 @@ For example, a bare-bones Post model may look like this in ActiveRecord:
501496
The same model may look like this in Mongoid:
502497

503498
.. code-block:: ruby
504-
:name: app/models/post.rb
505499
:caption: app/models/post.rb
506500

507501
class Post
@@ -516,7 +510,6 @@ The same model may look like this in Mongoid:
516510
Or like this with dynamic fields:
517511

518512
.. code-block:: ruby
519-
:name: app/models/post.rb
520513
:caption: app/models/post.rb
521514

522515
class Post
@@ -555,5 +548,5 @@ as when creating a regular application, with the only change being the
555548
Mongoid follows the same process described above for regular Rails applications.
556549

557550
A complete Rails API application similar to the one described in this tutorial
558-
can be found in the `mongoid-demo GitHub repository
551+
can be found in `the mongoid-demo GitHub repository
559552
<https://github.com/mongoid/mongoid-demo/tree/master/rails-api>`_.

0 commit comments

Comments
 (0)