Skip to content

Commit b37055c

Browse files
committed
Merge branch 'master' into littledata-docs-update
2 parents 3f90606 + 03bd39c commit b37055c

File tree

117 files changed

+14407
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+14407
-387
lines changed

CODEOWNERS

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# The default owners for everything in
22
# the repo. Unless a later match takes precedence.
3-
CODEOWNERS @segmentio/segment-doc-team
3+
CODEOWNERS @segmentio/segment-doc-team @sanscontext @markzegarelli
44

55
# Diagram library
6-
/diagram-library @sanscontext
6+
/diagram-library @sanscontext @markzegarelli
77

88
# Utility scripts
9-
/scripts @segmentio/segment-doc-team @XavierAgostini
9+
/scripts @segmentio/segment-doc-team
1010

1111
# Vale Linting
1212
/vale-styles @segmentio/segment-doc-team
1313
.vale.ini @segmentio/segment-doc-team
1414

15+
1516
# Content owners should be in the order of PM, TL (team-lead), and EM (in a crisis) for a given team.
1617
# This team will receive review requests automatically when a PR is submitted modifying the files in
1718
# a given directory+subtree, or file type, etc. that matches below. While Github won't enforce the
@@ -23,16 +24,16 @@ CODEOWNERS @segmentio/segment-doc-team
2324
# Libraries owners
2425
/src/connections/catalog/libraries @osamakhn @bsneed @pooyaj @juliofarah
2526

26-
# Destination owners
27+
# Destinations owners
2728
/src/connections/destinations @segmentio/segment-doc-team
2829

2930

30-
# Privacy owners
31-
/src/privacy @notfelineit
31+
# Privacy owners TODO
32+
# /src/privacy
3233

3334

34-
# Protocols owners
35-
/src/protocols @francisco @rarchana2001asu
35+
# Protocols owners TODO
36+
# /src/protocols
3637

3738
# Partner Program owners
3839
/src/partners @misteryeo @n2parko @benhorowitz

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ group :jekyll_plugins do
1717
gem 'jekyll-redirect-from'
1818
gem "premonition", "~> 2.0.0"
1919
gem "jekyll-include-cache"
20+
gem 'jekyll-algolia'
2021
end
2122

2223
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem

Gemfile.lock

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ GEM
2323
specs:
2424
addressable (2.7.0)
2525
public_suffix (>= 2.0.2, < 5.0)
26+
algolia_html_extractor (2.6.4)
27+
json (~> 2.0)
28+
nokogiri (~> 1.10)
29+
algoliasearch (1.27.5)
30+
httpclient (~> 2.8, >= 2.8.3)
31+
json (>= 1.5.1)
2632
colorator (1.1.0)
2733
commonmarker (0.21.0)
2834
ruby-enum (~> 0.5)
@@ -36,10 +42,21 @@ GEM
3642
multipart-post (>= 1.2, < 3)
3743
ruby2_keywords
3844
ffi (1.13.1)
45+
filesize (0.2.0)
3946
forwardable-extended (2.6.0)
4047
http_parser.rb (0.6.0)
48+
httpclient (2.8.3)
4149
i18n (1.8.5)
4250
concurrent-ruby (~> 1.0)
51+
jekyll-algolia (1.6.0)
52+
algolia_html_extractor (~> 2.6)
53+
algoliasearch (~> 1.26)
54+
filesize (~> 0.1)
55+
jekyll (>= 3.6, < 5.0)
56+
json (~> 2.0)
57+
nokogiri (~> 1.6)
58+
progressbar (~> 1.9)
59+
verbal_expressions (~> 0.1.5)
4360
jekyll-commonmark (1.3.1)
4461
commonmarker (~> 0.14)
4562
jekyll (>= 3.7, < 5.0)
@@ -56,6 +73,7 @@ GEM
5673
jekyll (>= 3.7, < 5.0)
5774
jekyll-watch (2.2.1)
5875
listen (~> 3.0)
76+
json (2.5.1)
5977
kramdown (2.3.0)
6078
rexml
6179
kramdown-parser-gfm (1.1.0)
@@ -67,12 +85,20 @@ GEM
6785
rb-fsevent (~> 0.10, >= 0.10.3)
6886
rb-inotify (~> 0.9, >= 0.9.10)
6987
mercenary (0.4.0)
88+
mini_portile2 (2.5.0)
7089
multipart-post (2.1.1)
90+
nokogiri (1.11.1)
91+
mini_portile2 (~> 2.5.0)
92+
racc (~> 1.4)
93+
nokogiri (1.11.1-x86_64-linux)
94+
racc (~> 1.4)
7195
pathutil (0.16.2)
7296
forwardable-extended (~> 2.6)
7397
posix-spawn (0.3.15)
7498
premonition (2.0.1)
99+
progressbar (1.11.0)
75100
public_suffix (4.0.6)
101+
racc (1.5.2)
76102
rake (13.0.1)
77103
rb-fsevent (0.10.4)
78104
rb-inotify (0.10.1)
@@ -93,6 +119,7 @@ GEM
93119
tzinfo-data (1.2020.4)
94120
tzinfo (>= 1.0.0)
95121
unicode-display_width (1.7.0)
122+
verbal_expressions (0.1.5)
96123
wdm (0.1.1)
97124

98125
PLATFORMS
@@ -103,6 +130,7 @@ DEPENDENCIES
103130
dotenv
104131
faraday
105132
jekyll!
133+
jekyll-algolia
106134
jekyll-commonmark
107135
jekyll-include-cache
108136
jekyll-last-modified-at

_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ plugins:
4949
- premonition
5050
- jekyll-commonmark
5151
- jekyll-last-modified-at
52+
algolia:
53+
application_id: UINQ2M4D9S
54+
index_name: segment-docs
55+
files_to_exclude:
56+
- _release_notes/*

devguide.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ Occasionally, a destination will change names. This shouldn't be too difficult t
3333
2. The programmatic content appears (cmodes, settings, previous names)
3434
3. The redirect from the old page URL works.
3535

36+
## All about the Catalog script
37+
38+
You run the Catalog update script by running `make catalog` from the docs repo. You, a person who is going to run the script, must first save a Segment token to an `.env` file locally, which is `gitignored` so we don’t check it in to gihub accidentally.
39+
40+
Note: Old ConfigAPI tokens are not compatible with Public API. You'll need a new one if you want to use Public API.
41+
42+
The script takes your token, inserts it into a request header, then contacts the API, downloads all the available metadata for destinations and sources. It then writes them into a series of yml files that the docs build can consume. (You can find these in `/src/_data/catalog/`)
43+
44+
Note: We don’t currently (Feb '21) do this for warehouses (storage dests) because they were originally lumped in with destinations, and didn’t change often enough to be worth writing a script for. We just have a static `warehouses.yml` file instead. With the switch to Public API from ConfigAPI, we should change this.
45+
46+
The script also “calculates” the values for the `connection-modes` table for destinations, but that’s a huge other headache.
47+
48+
It also does some slugification and destination-name normalization, since our handling of dots and dashes hasn't been consistent over time. Finally, it checks to see if there’s a folder for each destination. If it finds a new one, the script makes a folder with a “stub” markdown file for that destination, and then adds a line for it to an "incompleteDocs.txt" file. (It doesn't check to see if it's already listed, just appends to the file.)
49+
3650

3751
## Developer information
3852

js/algolia/index.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { html } from 'htm/preact';
2+
import algoliasearch from 'algoliasearch/lite';
3+
import { autocomplete, getAlgoliaHits, highlightHit } from '@algolia/autocomplete-js';
4+
import {createAlgoliaInsightsPlugin} from '@algolia/autocomplete-plugin-algolia-insights';
5+
import insightsClient from 'search-insights';
6+
7+
8+
const appId = 'UINQ2M4D9S';
9+
const apiKey = '636b6d9e2dfb207e89ea7344859848f9';
10+
const searchClient = algoliasearch(appId, apiKey);
11+
12+
//insights
13+
insightsClient('init', { appId, apiKey });
14+
const algoliaInsightsPlugin = createAlgoliaInsightsPlugin({ insightsClient });
15+
16+
17+
const search = autocomplete({
18+
container: '#autocomplete',
19+
placeholder: 'Search the Segment documentation',
20+
debug: false,
21+
openOnFocus: false,
22+
keyboardShortcuts: ['s', 191],
23+
plugins: [algoliaInsightsPlugin,],
24+
detachedMediaQuery:'none',
25+
getSources( {query} ) {
26+
return [
27+
{
28+
sourceId: 'articles',
29+
getItemUrl({ item }){
30+
if (item.anchor != null) {
31+
var itemUrl = item.url+"#" + item.anchor;
32+
} else {
33+
var itemUrl = item.url;
34+
}
35+
return itemUrl;
36+
},
37+
getItems() {
38+
return getAlgoliaHits({
39+
searchClient,
40+
queries: [
41+
{
42+
indexName: 'segment-docs',
43+
query,
44+
params: {
45+
hitsPerPage: 7,
46+
facetFilters: ['hidden:-true'],
47+
clickAnalytics: true,
48+
},
49+
},
50+
],
51+
});
52+
},
53+
templates: {
54+
item({ item }){
55+
if (item.anchor != null) {
56+
var anchorLink = "#" + item.anchor;
57+
} else {
58+
var anchorLink = "";
59+
}
60+
return html `<a class="aa-link" href="/docs${item.url}${anchorLink}">
61+
<p class="aa-title" >${highlightHit({hit: item, attribute: 'title'})}</h3>
62+
<p class="aa-heading">${item.headings.join(' >')}</p>
63+
<p class="aa-content">${highlightHit({hit: item, attribute: 'content'})}</p></a>
64+
`;
65+
},
66+
noResults() {
67+
return html `<p class="aa-content">No results for <strong>${query}</strong></p>`;
68+
}
69+
},
70+
71+
},
72+
];
73+
},
74+
navigator: {
75+
navigate({ itemUrl }) {
76+
window.location.assign('/docs'+itemUrl);
77+
},
78+
}
79+
});
80+

js/hoverhelp/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const COMPONENT_NAME = 'data-hoverhelp'
2+
const COMPONENT_SELECTOR = `[${COMPONENT_NAME}]`
3+
const BODY_SELECTOR = 'data-hoverhelp-body'
4+
const TRIGGER_SELECTOR = '[data-hoverhelp-target]'
5+
6+
export default function () {
7+
const components = document.querySelectorAll(COMPONENT_SELECTOR)
8+
9+
for (let i = 0; i < components.length; i++) {
10+
const triggers = components[i].querySelectorAll(TRIGGER_SELECTOR)
11+
12+
for (let i = 0; i < triggers.length; i++) {
13+
triggers[i].addEventListener('mouseover', e => {
14+
e.preventDefault()
15+
16+
const targetBody = document.querySelector(`[${BODY_SELECTOR}=${e.target.dataset.hoverhelpTarget}]`)
17+
18+
components[i].classList.toggle(components[i].dataset.activeClass)
19+
})
20+
}
21+
22+
document.addEventListener('mouseover', e => {
23+
if (components[i].classList.contains(components[i].dataset.activeClass)) {
24+
const hoverhelpBody = components[i].querySelector(`[${BODY_SELECTOR}]`)
25+
26+
for (let i = 0; i < triggers.length; i++) {
27+
if (!hoverhelpBody.contains(e.target) && e.target !== triggers[i]) {
28+
components[i].classList.remove(components[i].dataset.activeClass)
29+
}
30+
}
31+
}
32+
})
33+
}
34+
}

js/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dropdownMenu from './dropdown-menu'
99
import anchorsIndicator from './anchors-indicator'
1010
import codeExample from './code-example'
1111
import popover from './popover'
12+
import hoverhelp from './hoverhelp'
1213
import menuPanels from './menu-panels'
1314
import searchBar404 from './search-bar-404'
1415
import backScrolling from './back-scrolling'
@@ -18,6 +19,7 @@ import sideMenu from './side-menu'
1819
import tracking from './tracking'
1920
import searchBar from './search-bar'
2021
import glightbox from './glightbox'
22+
import autocomplete from './algolia'
2123
feedback()
2224
accordion()
2325
accordionGroup()
@@ -30,11 +32,12 @@ dropdownMenu()
3032
anchorsIndicator()
3133
codeExample()
3234
popover()
35+
hoverhelp()
3336
searchBar404()
3437
backScrolling()
3538
navigation()
3639
relativeLinks()
3740
sideMenu()
3841
tracking()
3942
searchBar()
40-
glightbox()
43+
glightbox()

js/search-navbar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function () {
2222
}
2323
}
2424

25-
document.getElementsByClassName('st-search-input')[0].addEventListener('click', function () {
25+
document.getElementsByClassName('aa-Input')[0].addEventListener('click', function () {
2626
typewriter.searchClicked()
2727
})
2828
}

js/tracking/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function() {
3535
};
3636
};
3737

38-
Array.from(document.querySelectorAll('.st-search-input')).forEach(searchInput => {
38+
Array.from(document.querySelectorAll('.aa-Input')).forEach(searchInput => {
3939
searchInput.addEventListener('input', debounce(function(e) {
4040
const query = e.target.value
4141
if (query.length) {

0 commit comments

Comments
 (0)