Skip to content

Commit b2ca691

Browse files
Merge pull request #308 from getsentry/docs/improve-dev-docs
Improve the dev docs
2 parents 7311fc0 + 3501ba9 commit b2ca691

File tree

21 files changed

+200
-282
lines changed

21 files changed

+200
-282
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ Documentation is written in Markdown, which is parsed by [kramdown](https://kram
4646

4747
[<kbd>Read the quick reference</kbd>](https://kramdown.gettalong.org/quickref.html)
4848

49-
## Layout components
49+
While the server is running, you can also view the [Markdown styleguide](http://0.0.0.0:9000/markdown-styleguide/links/)
5050

51-
While in dev mode, the sidebar includes documentation for the special components available for formatting content.
51+
## Custom components
52+
53+
While in dev mode, the sidebar includes documentation for the special tags and includes available for formatting content.
5254

5355
## Adding content
5456

_config.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: >-
33
Learn how to use Sentry, configure Sentry clients, and contribute to the open
44
source project on GitHub
55
meta_image: default.png
6-
baseurl: ""
7-
url: "https://docs.sentry.io"
6+
baseurl: ''
7+
url: 'https://docs.sentry.io'
88
twitter_username: getsentry
99
home_url: https://sentry.io
1010

@@ -31,12 +31,12 @@ collections:
3131

3232
defaults:
3333
- scope:
34-
path: ""
34+
path: ''
3535
type: pages
3636
values:
3737
layout: doc
3838
- scope:
39-
path: ""
39+
path: ''
4040
type: documentation
4141
values:
4242
layout: doc
@@ -47,11 +47,15 @@ defaults:
4747
# object does not get clobbered so we use that to only load the dev
4848
# in dev mode, and these defaults here are not used in production.
4949
- scope:
50-
path: ""
50+
path: ''
5151
type: dev_components
5252
values:
53-
layout: doc
53+
layout: dev/default
5454
permalink: /:path/
55+
- scope:
56+
path: collections/_dev_components/markdown-styleguide/*
57+
values:
58+
layout: doc
5559

5660
assets:
5761
source_maps: false # Prefer webpack sourcemaps
@@ -70,9 +74,8 @@ assets:
7074
- '*.ico'
7175
- 'meta/*'
7276

73-
7477
extlinks:
75-
attributes: {rel: nofollow}
78+
attributes: { rel: nofollow }
7679
rel_exclude: ['sentry.io', 'getsentry.com']
7780

7881
# Hack to give us an empty array prototype

bin/server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ rm -rf .jekyll-cache
4141
yarn
4242
(bundle check || bundle install)
4343

44-
./bin/webpack-watch & ./bin/jekyll-watch
44+
./bin/webpack-watch & ./bin/jekyll-watch

src/_data/dev_components_categories.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
icon: about-the-dsn
55
slug: markdown-styleguide
66

7-
- title: Layout Components
7+
- title: Includes
88
icon: workflow
9-
slug: layout-components
9+
slug: includes
10+
11+
- title: Tags
12+
icon: workflow
13+
slug: tags

src/_includes/breadcrumbs.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{%- assign __path = page.url
22
| replace: "collections/_documentation/", ""
3+
| replace: "collections/_dev_components/", ""
34
| split: '/'
45
| pop
56
-%}
@@ -16,7 +17,11 @@
1617
{%- if __page -%}
1718
<li class="breadcrumb-item"><a href="{{ __page.url }}">{{ __page.breadcrumb | default: __page.title }}</a></li>
1819
{%- else -%}
19-
{%- assign __cateogry = site.data.documentation_categories
20+
{%- assign __categories = site.data.documentation_categories -%}
21+
{% if jekyll.environment == "development" %}
22+
{%- assign __categories = __categories | concat: site.data.dev_components_categories -%}
23+
{%- endif -%}
24+
{%- assign __cateogry = __categories
2025
| where: 'slug', __segment
2126
| first
2227
-%}

src/_js/lib/DynamicLoad.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class DynamicLoader {
9595
$('body').addClass('loading');
9696
loader({ pathname, hash, search })
9797
.then(html => {
98+
$(document).trigger('page.willUpdate');
9899
$('body').removeClass('loading');
99100
if (html) replaceContent(html);
100101
done();

src/_js/lib/Sidebar.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
const onlyCategories = (i, el) => {
2-
const $parents = $(el).parentsUntil(
3-
'[data-sidebar-root]',
4-
'[data-sidebar-tree]'
5-
);
6-
return $parents.length === 1;
1+
const filterDepth = depth => {
2+
return (i, el) => {
3+
const $parents = $(el).parentsUntil(
4+
'[data-sidebar-root]',
5+
'[data-sidebar-tree]'
6+
);
7+
return $parents.length === depth;
8+
};
79
};
810

911
$(document).on('page.didUpdate', function(event) {
1012
const $links = $('[data-sidebar-link]');
1113
let $active = $links.filter(`[href="${location.pathname}"]`);
14+
const $categoryTree = $('[data-sidebar-tree]').filter(filterDepth(1));
1215
$active = !!$active.length
1316
? $active
14-
: $('[data-sidebar-tree]')
15-
.filter(onlyCategories)
16-
.eq(0)
17-
.siblings('[data-sidebar-link]');
17+
: $categoryTree.first().siblings('[data-sidebar-link]');
1818

1919
$links.each((i, el) => {
2020
const $el = $(el);
2121
$el.toggleClass('active', $el.is($active));
2222
});
2323

24+
const $sectionTree = $('[data-sidebar-tree]').filter(filterDepth(0));
25+
2426
const $trees = $('[data-sidebar-tree]');
2527
$trees.each((i, el) => {
2628
const $el = $(el);
2729
const containsActive = !!$el.has($active.get(0)).length;
2830
const isChildOfActive = $el.parent().is($active.parent());
29-
$el.toggleClass('collapse', !(containsActive || isChildOfActive));
31+
const isSection = $sectionTree.is($el);
32+
const leaveVisble = containsActive || isChildOfActive || isSection;
33+
$el.toggleClass('collapse', !leaveVisble);
3034
});
3135
});

src/_js/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ if (process.env.NODE_ENV === 'production') {
1515
Raven.config(dsn).install();
1616
}
1717

18+
$(document).on('page.willUpdate', function(event) {
19+
$('[data-toggle="tooltip"]').tooltip('dispose');
20+
});
21+
1822
$(document).on('page.didUpdate', function(event) {
1923
$('[data-toggle="tooltip"]').tooltip();
2024
});

src/_layouts/dev/default.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: doc
3+
---
4+
5+
{{ page.content }}
6+
7+
{%- if page.arguments.size > 0 -%}
8+
<h4>Arguments</h4>
9+
10+
<div class="list-group">
11+
{%- for arg in page.arguments -%}
12+
13+
<div class="list-group-item content-flush-bottom">
14+
<div class="d-flex w-100 justify-content-between">
15+
<h5 class="mb-1"><code>{{ arg.name }}</code></h5>
16+
<small>{% if arg.required %}<strong>(Required)</strong>{% else %}(Optional){% endif %}</small>
17+
</div>
18+
{{ arg.desc | markdownify }}
19+
</div>
20+
{%- endfor -%}
21+
</div>
22+
{%- endif -%}
23+
24+
<hr>
25+
26+
{%- for example in page.examples -%}
27+
{%- if example.title -%}<h3>{{ example.title }}</h3>{%- endif -%}
28+
29+
{%- if example.desc -%}
30+
{{ example.desc | liquify | markdownify }}
31+
{%- endif -%}
32+
33+
<h4>Source</h4>
34+
35+
{%- highlight liquid -%}{{- example.source -}}{%- endhighlight -%}
36+
37+
<h4>Output</h4>
38+
39+
<div class="p-3 mb-3 mb-md-5 border rounded content-flush-bottom">
40+
{{ example.output | default: example.source | liquify | markdownify }}
41+
</div>
42+
43+
{%- endfor -%}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Alert
3+
arguments:
4+
- name: content=""
5+
type: String
6+
required: true
7+
desc: Content for the alert
8+
- name: title=""
9+
type: String
10+
required: false
11+
desc: Title for the alert
12+
- name: level=""
13+
type: String
14+
required: false
15+
desc: Severity of the alert. Must be a valid [Bootstrap severity level](https://getbootstrap.com/docs/4.0/components/alerts/).
16+
examples:
17+
- title: Basic use
18+
source: |
19+
{% include components/alert.html
20+
content="This is the body of the alert"
21+
%}
22+
- title: Full markdown content
23+
source: |
24+
{% capture markdown_content %}
25+
This paragraph explains that it will be followed by a list.
26+
27+
- This list has three items
28+
- This is the second item
29+
- The last item is the best
30+
{% endcapture %}
31+
{% include components/alert.html
32+
content=markdown_content
33+
%}
34+
- title: Kitchen sink
35+
source: |
36+
{% include components/alert.html
37+
title="Pay attention"
38+
content="This is the body of the alert"
39+
level="danger"
40+
%}
41+
---
42+
43+
A box with content, with optional colors
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Platform Content
3+
example_string: Hello World
4+
arguments:
5+
- name: 'content_dir="my-example"'
6+
type: String
7+
required: true
8+
desc: Name of the folder where the examples are stored, relative to the current document
9+
examples:
10+
- title: Basic use
11+
desc: |
12+
#### File Structure
13+
14+
```
15+
_documentation/this-category/
16+
this-document.md
17+
example-1/
18+
javascript.md
19+
python.md
20+
ruby.md
21+
```
22+
source: |
23+
{% include components/platform_content.html content_dir="example_1" %}
24+
---
25+
26+
You can customize content by platform. Within a folder in the same directory as your document, add a file for each platform you would like to include, ensuring that name of the file matches a slug in *src/data/platforms.yml*, then use the include to specify which folder to include examples from.
27+
28+
Content is run through the Liquid compiler, then through the Markdown compiler, making it possible to create dynamic, rich styled content.
29+
30+
The switcher will globally remember the prefered language and load it by default until changed. If no prefered language is set, the first langage provided is the default. A content platform content block does not contain the preferred language, it will display the default language for the block.
31+
32+
You may force the platform that is displayed on the page by appending a `platform=javascript` query parameter to the page url. This will cause subsequent pages in the browsing session to display that platform. Removing the query parameter will set the page back to the default behavior of looking for the prefered platform
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: User Content
3+
examples:
4+
- title: Basic use
5+
desc: |
6+
{% include components/alert.html content="Do not copy and paste from this example. It contains invisible characters that prevent the tokens from rendering." %}
7+
source: |
8+
```javascript
9+
console.log("Your DSN is _⁣__DSN___")
10+
```
11+
output: |
12+
```javascript
13+
console.log("Your DSN is ___DSN___")
14+
```
15+
---
16+
17+
It is possible to display a user's actual configuration information within code samples. This is done using one of the following keys:
18+
19+
<div data-user-token-list></div>
20+
21+
This feature only works within block level code examples, which are created using tripple tick <code>```</code> fenced code blocks in Markdown or using Jekyll's `highlight` tag.

0 commit comments

Comments
 (0)