Skip to content

Commit 98e5ff5

Browse files
tonyountitaker
authored andcommitted
docs: Build docs on Travis (#63)
* docs: Build docs on Travis * docs: Update Python snippets in README.md
1 parent 7c6f107 commit 98e5ff5

File tree

5 files changed

+90
-45
lines changed

5 files changed

+90
-45
lines changed

.craft.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ github:
33
owner: getsentry
44
repo: sentry-python
55
targets:
6-
- name: github
76
- name: pypi
7+
- name: github
8+
- name: gh-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pip-log.txt
1515
.idea
1616
.eggs
1717
venv
18+
.venv
1819
.vscode/tags
1920
.pytest_cache
2021
.hypothesis

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ matrix:
2828
- python: "3.8-dev"
2929
dist: xenial
3030
sudo: true
31-
- python: "3.6"
31+
32+
- name: Linting
33+
python: "3.6"
34+
install:
35+
- pip install tox
3236
script: tox -e linters
3337
- python: "3.6"
34-
env: DIST=1
35-
script: make dist
36-
after_success:
37-
- npm install -g @zeus-ci/cli
38-
- zeus upload -t "application/zip+wheel" dist/*
38+
name: Distribution packages
39+
install: false
40+
script: make travis-upload-dist
41+
- python: "3.6"
42+
name: Build documentation
43+
install: false
44+
script: make travis-upload-docs
3945

4046
install:
4147
- curl https://sh.rustup.rs -sSf | sh -s -- -y

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,20 @@ apidocs:
2929
@pip install pdoc pygments
3030
@pdoc --overwrite --html --html-dir build/apidocs sentry_sdk
3131
.PHONY: apidocs
32+
33+
install-zeus-cli:
34+
npm install -g @zeus-ci/cli
35+
.PHONY: install-zeus-cli
36+
37+
travis-upload-docs:
38+
@pip install --editable .
39+
$(MAKE) apidocs
40+
cd build/apidocs && zip -r gh-pages ./sentry_sdk
41+
$(MAKE) install-zeus-cli
42+
zeus upload -t "application/zip+docs" build/apidocs/gh-pages.zip
43+
.PHONY: travis-upload-docs
44+
45+
travis-upload-dist: dist
46+
$(MAKE) install-zeus-cli
47+
zeus upload -t "application/zip+wheel" dist/*
48+
.PHONY: travis-upload-dist

README.md

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,46 @@
1515

1616
Install this package with ``pip install sentry-sdk``. Then, in your code:
1717

18-
import sentry_sdk
19-
sentry_sdk.init(dsn="https://[email protected]/123")
18+
```python
19+
import sentry_sdk
20+
sentry_sdk.init(dsn="https://[email protected]/123")
21+
```
2022

2123
After initialization, you can capture exceptions like this:
2224

23-
sentry_sdk.capture_exception(ValueError())
25+
```python
26+
sentry_sdk.capture_exception(ValueError())
2427

25-
try:
26-
raise ValueError()
27-
except Exception:
28-
sentry_sdk.capture_exception()
28+
try:
29+
raise ValueError()
30+
except Exception:
31+
sentry_sdk.capture_exception()
32+
```
2933

3034
...or send messages:
3135

32-
sentry_sdk.capture_message("Hi Sentry!")
36+
```python
37+
sentry_sdk.capture_message("Hi Sentry!")
38+
```
3339

3440
## Scopes (contexts, tags)
3541

3642
You can create a scope to attach data to all events happening inside of it:
3743

38-
with sentry_sdk.Hub.current.push_scope():
39-
with sentry_sdk.configure_scope() as scope:
40-
scope.transaction = "my_view_name"
41-
scope.set_tag("key", "value")
42-
scope.user = {"id": 123}
43-
44-
# ValueError event will have all that data attached
45-
capture_exception(ValueError())
44+
```python
45+
with sentry_sdk.Hub.current.push_scope():
46+
with sentry_sdk.configure_scope() as scope:
47+
scope.transaction = "my_view_name"
48+
scope.set_tag("key", "value")
49+
scope.user = {"id": 123}
4650

47-
# This one not since it is outside of the context manager
51+
# ValueError event will have all that data attached
4852
capture_exception(ValueError())
4953

54+
# This one not since it is outside of the context manager
55+
capture_exception(ValueError())
56+
```
57+
5058
Scopes can be nested. If you call ``push_scope`` inside of the
5159
``with``-statement again, that scope will be pushed onto a stack. It will also
5260
inherit all data from the outer scope.
@@ -56,23 +64,29 @@ inherit all data from the outer scope.
5664
If you never call ``init``, no data will ever get sent to any server. In such
5765
situations, code like this is essentially deadweight:
5866

59-
with sentry_sdk.configure_scope() as scope:
60-
scope.user = _get_user_data()
67+
```python
68+
with sentry_sdk.configure_scope() as scope:
69+
scope.user = _get_user_data()
70+
```
6171

6272
Sentry-Python supports an alternative syntax for configuring a scope that
6373
solves this problem:
6474

65-
@sentry_sdk.configure_scope
66-
def _(scope):
67-
scope.user = _get_user_data()
75+
```python
76+
@sentry_sdk.configure_scope
77+
def _(scope):
78+
scope.user = _get_user_data()
79+
```
6880

6981
Your function will just not be executed if there is no client configured.
7082

7183
In your testing and development environment you still might want to run that
7284
code without sending any events. In that case, simply call ``init`` without a
7385
DSN:
7486

75-
sentry_sdk.init()
87+
```python
88+
sentry_sdk.init()
89+
```
7690

7791
### Breadcrumbs
7892

@@ -81,23 +95,27 @@ anywhere in your system ends up as a breadcrumb, see [the logging
8195
docs](./docs/logging.md) for more information. You can, however, also create
8296
breadcrumbs manually:
8397

84-
sentry_sdk.add_breadcrumb(
85-
timestamp=datetime.datetime.now(),
86-
type="log",
87-
level="debug",
88-
# message="hi",
89-
# category="myapp.models",
90-
})
98+
```python
99+
sentry_sdk.add_breadcrumb(
100+
timestamp=datetime.datetime.now(),
101+
type="log",
102+
level="debug",
103+
# message="hi",
104+
# category="myapp.models",
105+
})
106+
```
91107

92108
You can also pass a callback to `add_breadcrumb` like so:
93109

94-
sentry_sdk.add_breadcrumb(lambda: {
95-
"timestamp": datetime.datetime.now(),
96-
"type": "log",
97-
"level": "debug",
98-
# "message": "hi",
99-
# "category": "myapp.models",
100-
})
110+
```python
111+
sentry_sdk.add_breadcrumb(lambda: {
112+
"timestamp": datetime.datetime.now(),
113+
"type": "log",
114+
"level": "debug",
115+
# "message": "hi",
116+
# "category": "myapp.models",
117+
})
118+
```
101119

102120
The callback will only be called if a sentry client is configured.
103121

@@ -118,7 +136,9 @@ Currently Sentry-Python does not send any personally-identifiable user data
118136
with events by default. You need to explicitly enable this behavior with the
119137
``send_default_pii`` option passed to ``init``:
120138

121-
init(..., send_default_pii=True)
139+
```python
140+
init(..., send_default_pii=True)
141+
```
122142

123143
## Integrations
124144

0 commit comments

Comments
 (0)