Skip to content

DOCSP-565 - Implemented tabbed layout on CRUD pages. Included Python … #2862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ composite-pages.yaml
!bin/*/mongodb-domain.yaml
meta.yaml
build
driver-examples/
*~
source/reference/*/*.rst
source/reference/*/*/*.rst
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ PRODUCTION_BUCKET=docs-mongodb-org-prod
# within one bucket. For the manual it is empty.
PROJECT=

DRIVERS_PATH=source/driver-examples

BLOCKS_FILE=./build/${GIT_BRANCH}/tests.blocks
TEST_FILE=./build/${GIT_BRANCH}/tests.js
.PHONY: help lint html stage deploy
Expand All @@ -27,10 +29,10 @@ test: html ## Runs test framework over the corpus
node ./build/docs-tools/tools/rst-testing/compile-blocks.js ${BLOCKS_FILE} > ${TEST_FILE}
./build/docs-tools/tools/rst-testing/rst_tester.py ${TEST_FILE}

html: ## Builds this branch's HTML under build/<branch>/html
html: examples ## Builds this branch's HTML under build/<branch>/html
giza make html

publish: ## Builds this branch's publishable HTML and other artifacts under build/public
publish: examples ## Builds this branch's publishable HTML and other artifacts under build/public
giza make publish

# - Enter build/<branch>/html, and recurse over each regular file
Expand Down Expand Up @@ -62,3 +64,10 @@ deploy: build/public ## Deploy to the production bucket
mut-publish build/public ${PRODUCTION_BUCKET} --prefix=${PROJECT} --deploy --redirect-prefix='v[0-9]\.[0-9]' --redirect-prefix='manual' --redirect-prefix='master' ${ARGS}

@echo "Hosted at ${PRODUCTION_URL}/index.html"

examples: examples-python

# Something about Python example
examples-python:
mkdir -p ${DRIVERS_PATH}
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-python-driver/master/test/test_examples.py -o ${DRIVERS_PATH}/test_examples.py
3 changes: 2 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def has(self, *args):
'mongodb',
'directives',
'intermanual',
'testcode'
'testcode',
'template'
]

locale_dirs = [ os.path.join(conf.paths.projectroot, conf.paths.locale) ]
Expand Down
4 changes: 4 additions & 0 deletions config/intersphinx.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: python2
url: https://docs.python.org/2/
path: python2.inv
---
name: pymongo
url: http://api.mongodb.com/python/current/
path: pymongo.inv
...
32 changes: 32 additions & 0 deletions source/includes/driver-example-delete-55.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.insertMany( [
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
]);

.. only:: website

You can run the operation in the web shell below:

.. include:: /includes/fact-mws.rst

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 55
:end-before: End Example 55
20 changes: 20 additions & 0 deletions source/includes/driver-example-delete-56.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.deleteMany({})

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 56
:end-before: End Example 56
20 changes: 20 additions & 0 deletions source/includes/driver-example-delete-57.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.deleteMany({ status : "A" })

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 57
:end-before: End Example 57
20 changes: 20 additions & 0 deletions source/includes/driver-example-delete-58.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.deleteOne( { status: "D" } )

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 58
:end-before: End Example 58
15 changes: 15 additions & 0 deletions source/includes/driver-example-delete-result.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
The method returns a document with the status of the operation. For
more information and examples, see :method:`~db.collection.deleteMany()`.

- id: python
content: |
The :py:meth:`~pymongo.collection.Collection.delete_many`
method returns an instance of
:py:class:`pymongo.results.DeleteResult` with the status of the operation.
28 changes: 28 additions & 0 deletions source/includes/driver-example-insert-1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.insertOne(
{ item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } }
)

.. only:: website

You can run the operation in the web shell below:

.. include:: /includes/fact-mws.rst

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 1
:end-before: End Example 1
20 changes: 20 additions & 0 deletions source/includes/driver-example-insert-2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( { item: "canvas" } )

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 2
:end-before: End Example 2
30 changes: 30 additions & 0 deletions source/includes/driver-example-insert-3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.insertMany([
{ item: "journal", qty: 25, tags: ["blank", "red"], size: { h: 14, w: 21, uom: "cm" } },
{ item: "mat", qty: 85, tags: ["gray"], size: { h: 27.9, w: 35.5, uom: "cm" } },
{ item: "mousepad", qty: 25, tags: ["gel", "blue"], size: { h: 19, w: 22.85, uom: "cm" } }
])

.. only:: website

You can run the operation in the web shell below:

.. include:: /includes/fact-mws.rst

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 3
:end-before: End Example 3
20 changes: 20 additions & 0 deletions source/includes/driver-example-query-10.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( { status: { $in: [ "A", "D" ] } } )

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 10
:end-before: End Example 10
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-11.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( { status: "A", qty: { $lt: 30 } } )


- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 11
:end-before: End Example 11
21 changes: 21 additions & 0 deletions source/includes/driver-example-query-12.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( { $or: [ { status: "A" }, { qty: { $lt: 30 } } ] } )


- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 12
:end-before: End Example 12
24 changes: 24 additions & 0 deletions source/includes/driver-example-query-13.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( {
status: "A",
$or: [ { qty: { $lt: 30 } }, { item: /^p/ } ]
} )


- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 13
:end-before: End Example 13
32 changes: 32 additions & 0 deletions source/includes/driver-example-query-14.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.insertMany( [
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);

.. only:: website

You can run the operation in the web shell below:

.. include:: /includes/fact-mws.rst

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 14
:end-before: End Example 14
20 changes: 20 additions & 0 deletions source/includes/driver-example-query-15.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: /includes/templates/tabs.rst

.. tabs::

tabs:
- id: shell
content: |
.. class:: copyable-code
.. code-block:: javascript

db.inventory.find( { size: { h: 14, w: 21, uom: "cm" } } )

- id: python
content: |
.. class:: copyable-code
.. literalinclude:: /driver-examples/test_examples.py
:language: python
:dedent: 8
:start-after: Start Example 15
:end-before: End Example 15
Loading