Skip to content

Commit bf8e4f9

Browse files
skerschbkay-kim
authored andcommitted
DOCSP-2432: uriwriter prereqs (#63)
1 parent 120c84e commit bf8e4f9

24 files changed

+505
-111
lines changed

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PROJECT=guides
1111

1212
DRIVERS_PATH=source/driver-examples
1313

14-
.PHONY: help html publish stage deploy deploy-search-index
14+
.PHONY: examples help html publish stage deploy deploy-search-index
1515

1616
help: ## Show this help message
1717
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@@ -57,15 +57,28 @@ examples:
5757
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/tests/MongoDB.Driver.Examples/DocumentationExamples.cs -o ${DRIVERS_PATH}/DocumentationExamples.cs
5858
curl -SfL https://raw.githubusercontent.com/mongodb/node-mongodb-native/master/test/functional/operation_changestream_example_tests.js -o ${DRIVERS_PATH}/ChangeStreamNodeExamples.js
5959
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/tests/MongoDB.Driver.Examples/ChangeStreamExamples.cs -o ${DRIVERS_PATH}/ChangeStreamExamples.cs
60-
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-c-driver/master/tests/test-mongoc-sample-commands.c -o ${DRIVERS_PATH}/test-mongoc-sample-commands.c
60+
#curl -SfL https://raw.githubusercontent.com/mongodb/mongo-c-driver/master/tests/test-mongoc-sample-commands.c -o ${DRIVERS_PATH}/test-mongoc-sample-commands.c
6161
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-java-driver-reactivestreams/master/examples/documentation/src/DocumentationSamples.java -o ${DRIVERS_PATH}/AsyncDocumentationSamples.java
62-
cp /examples/java/ConnectExample.java ${DRIVERS_PATH}/JavaConnectDocumentationSamples.java
63-
cp /examples/python/connect/connect.py ${DRIVERS_PATH}/connect.py
64-
cp /examples/python/connect/connect.py ${DRIVERS_PATH}/connect.py
65-
cp /examples/node/connect/connect.js ${DRIVERS_PATH}/connect.js
62+
cp examples/java/ConnectExample.java ${DRIVERS_PATH}/JavaConnectExample.java
63+
cp examples/java/Connect.java ${DRIVERS_PATH}/JavaConnectTest.java
64+
cp examples/csharp/Connect.cs ${DRIVERS_PATH}/csharpconnect.cs
65+
cp examples/python/connect/connect.py ${DRIVERS_PATH}/connect.py
66+
cp examples/motor/connect/connect.py ${DRIVERS_PATH}/motorconnect.py
67+
cp examples/python/connect/connecttest.py ${DRIVERS_PATH}/connecttest.py
68+
cp examples/node/connect/connect.js ${DRIVERS_PATH}/connect.js
6669

6770

6871
install-resources: ## Retrieves the generated installation resources from the mongodb/docs repo
6972
curl -SfL https://raw.githubusercontent.com/mongodb/docs/v3.6/source/includes/release-base.yaml -o source/includes/release-base.yaml
7073
curl -SfL https://raw.githubusercontent.com/mongodb/docs/v3.6/source/includes/release-specifications.yaml -o source/includes/release-specifications.yaml
7174
curl -SfL https://raw.githubusercontent.com/mongodb/docs/v3.6/source/includes/fact-install-windows.rst -o source/includes/fact-install-windows.rst
75+
76+
screenshots:
77+
giza generate assets
78+
@echo "Running screenshot tool"
79+
-rm -r screenshots-temp/guides
80+
mkdir -p screenshots-temp/guides
81+
cd build/docs-tools/tools/screenshot-tool && npm install
82+
node build/docs-tools/tools/screenshot-tool/screenshots.js `pwd`/screenshot-scripts/guides-connectionstringcompass.js `pwd`/screenshot-scripts/.properties.ini
83+
node build/docs-tools/tools/screenshot-tool/screenshots.js `pwd`/screenshot-scripts/guides-connectionstringdrivers.js `pwd`/screenshot-scripts/.properties.ini
84+
node build/docs-tools/tools/screenshot-tool/screenshots.js `pwd`/screenshot-scripts/guides-connectionstring.js `pwd`/screenshot-scripts/.properties.ini

examples/csharp/Connect.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Start Connect
2+
using System;
3+
using MongoDB.Bson;
4+
using MongoDB.Driver;
5+
6+
namespace csharptest
7+
{
8+
class Connect
9+
{
10+
static void Main(string[] args)
11+
{
12+
var client = new MongoClient("<URISTRING>");
13+
}
14+
}
15+
}
16+
17+
// End Connect

examples/java/Connect.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.mongodb.docs.guides.examples.crud;
2+
3+
// Start Connect
4+
import com.mongodb.MongoClient;
5+
import com.mongodb.MongoClientURI;
6+
7+
public class Connect {
8+
9+
public static MongoClient getConnection() {
10+
11+
// here is the uri string!
12+
final String uriString = "<URISTRING>";
13+
14+
MongoClientURI uri = new MongoClientURI(uriString);
15+
// note that java connections are not initialized unless an operation
16+
// such as a find() or count() is executed
17+
18+
return new MongoClient(uri);
19+
20+
}
21+
22+
public static void closeConnection(MongoClient client) {
23+
client.close();
24+
}
25+
}
26+
// End Connect

examples/java/ConnectExample.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.mongodb.docs.guides.examples.crud;
22

3-
43
import org.bson.Document;
54

65
import com.mongodb.Block;
@@ -29,18 +28,20 @@ public static void main(String args[]) {
2928

3029
private static void testCollectionBinding() {
3130

32-
final String uriString = "mongodb://testuser:<PASSWORD>@localhost:27017/test?authSource=admin";
31+
// final String uriString = "mongodb://testuser:password@localhost:27017/test?authSource=admin";
3332

34-
MongoClientURI uri = new MongoClientURI(uriString);
33+
// MongoClientURI uri = new MongoClientURI(uriString);
3534
// note that java connections are not initialized unless an operation
3635
// such as a find() or count() is executed
3736

38-
MongoClient mongoClient = new MongoClient(uri);
39-
37+
// Start Connection
38+
MongoClient mongoClient = Connect.getConnection();
39+
// End Connection
40+
// Start Collection Bind
4041
MongoDatabase db = mongoClient.getDatabase("test");
4142
MongoCollection<Document> collection = db
4243
.getCollection("inventory");
43-
44+
// End Collection Bind
4445
collection.drop();
4546

4647
// Insert Guide test
@@ -109,6 +110,7 @@ public void apply(final Document document) {
109110

110111
findIterable.forEach(printBlock);
111112

113+
112114
findIterable = collection.find(or(eq("status", "A"), lt("qty", 30)));
113115

114116
System.out.println("READ GUIDE 3: example 3 results");
@@ -123,10 +125,11 @@ public void apply(final Document document) {
123125

124126
findIterable.forEach(printBlock);
125127

126-
mongoClient.close();
128+
// Start Close
129+
Connect.closeConnection(mongoClient);
127130

131+
// End Close
128132
}
129-
}
130-
131133

134+
}
132135

examples/motor/connect/connect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#Start Connect
12
import motor.motor_asyncio
23
import asyncio
34
import pprint
45

5-
client = motor.motor_asyncio.AsyncIOMotorClient('mongodb://testuser:<PASSWORD>@localhost:27017/test?authSource=admin');
6+
client = motor.motor_asyncio.AsyncIOMotorClient('<URISTRING>')
7+
#End Connect
68
db = client.test
7-
9+
#Start Close
810
client.close()
9-
11+
#End Close

examples/node/connect/bind.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/node/connect/connect.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Start Connect
2+
const MongoClient = require('mongodb').MongoClient;
3+
const assert = require('assert');
4+
5+
// Connection URL
6+
const url = '<URISTRING>';
7+
8+
// Use connect method to connect to the Server
9+
MongoClient.connect(url, function(err, client) {
10+
assert.equal(null, err);
11+
client.close();
12+
});
13+
// End Connect

examples/python/connect/connect.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# Start Connection
1+
#Start Connect
22
from pymongo import MongoClient
3-
from pprint import pprint
4-
import json
53

6-
connection_string = "mongodb://testuser:<PASSWORD>@localhost:27017/test?authSource=admin"
7-
client = MongoClient(connection_string)
8-
# End Connection
9-
10-
# Start DatabaseBind
11-
db = client.test
12-
# End DatabaseBind
13-
14-
client.close()
4+
class Connect():
5+
def get_connection(self):
6+
connection_string = "<URISTRING>"
7+
client = MongoClient(connection_string)
8+
return client
9+
#End Connect
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
#Start Caller Connect
3+
from connect import Connect
4+
from pymongo import MongoClient
5+
6+
client = Connect()
7+
connection = client.get_connection()
8+
#End Caller Connect
9+
assert connection is not None
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
'use strict';
2+
3+
const screenshotNames = ['connectionstring.png'];
4+
const screenshotDir = './screenshots-temp';
5+
const origImageDir = './source/images';
6+
7+
exports.run = async function (options) {
8+
const nightmare = options.nightmare;
9+
const originalPath = `${origImageDir}/${screenshotNames[0]}`;
10+
const screenshotPath = `${screenshotDir}/${screenshotNames[0]}`;
11+
12+
await options.loginToAtlas()
13+
await nightmare.wait(2000)
14+
await nightmare.wait('.mms-body-main')
15+
await nightmare.click('.js-connect')
16+
await nightmare.wait(2000)
17+
await nightmare.click('div.view-modal-layout > div > div > div > ol > li:nth-child(2) > button');
18+
await nightmare.wait('.view-modal-layout')
19+
await nightmare.click('div.js-modal-container > div > div > div > div > div.view-modal-layout > div > div > ol > li:nth-child(2) > div > button:nth-child(2)')
20+
await nightmare.wait('.view-modal-content')
21+
const button_clip = await nightmare.evaluate(() => {
22+
// store the button in a variable
23+
const build_cluster_btn = document.querySelector('.view-modal-content');
24+
// use the getClientRects() function on the button to determine
25+
// the size and location
26+
const [rect] = build_cluster_btn.getClientRects();
27+
console.log([rect]);
28+
// convert the rectangle to a clip object and return it
29+
return {
30+
top: rect.top,
31+
right: rect.right,
32+
bottom: rect.bottom,
33+
left: rect.left,
34+
width: rect.width,
35+
height: rect.height
36+
};
37+
})
38+
const buildClip = {
39+
x: Math.floor(button_clip.left)-20,
40+
y: Math.floor(button_clip.top)-20,
41+
width: Math.floor(button_clip.width)+40,
42+
height: Math.floor(button_clip.height)+40
43+
};
44+
await nightmare.screenshot(screenshotPath, buildClip)
45+
await nightmare.wait(500)
46+
await nightmare.end();
47+
48+
return [[originalPath, screenshotPath]];
49+
}
50+
51+
exports.nightmare_props = {
52+
show: true,
53+
typeInterval: 20,
54+
height: 1500,
55+
width: 1000,
56+
webPreferences: {
57+
zoomFactor: .9
58+
}
59+
}

0 commit comments

Comments
 (0)