Skip to content

Commit

Permalink
Merge pull request #35 from octue/release/0.0.12
Browse files Browse the repository at this point in the history
Alpha Release/0.0.12
  • Loading branch information
thclark authored Aug 16, 2020
2 parents a2cff11 + a9cf780 commit f912c89
Show file tree
Hide file tree
Showing 39 changed files with 2,280 additions and 499 deletions.
19 changes: 17 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
exclude: 'build|docs|node_modules|.git|.tox|dist|docs|octue.egg-info|twined.egg-info'
include: 'twined'
default_stages: [commit]
fail_fast: true
default_language_version:
Expand Down Expand Up @@ -33,7 +32,23 @@ repos:
language_version: python3

- repo: https://github.com/thclark/pre-commit-sphinx
rev: 0.0.1
rev: master
hooks:
- id: build-docs
language_version: python3

- repo: https://github.com/windpioneers/pre-commit-hooks
rev: 0.0.5
hooks:
- id: check-branch-name
args:
- '^master$'
- '^development$'
- '^devops/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^doc/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^experiment/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^feature/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^fix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^hotfix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^review/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^release/(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
29 changes: 29 additions & 0 deletions docs/source/_ext/googleanalytics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from sphinx.errors import ExtensionError


def add_ga_javascript(app, pagename, templatename, context, doctree):
if app.config.googleanalytics_enabled:
id = app.config.googleanalytics_id
metatags = context.get('metatags', '')
metatags += "<!-- Global site tag (gtag.js) - Google Analytics -->\n"
metatags += f'<script async src="https://www.googletagmanager.com/gtag/js?id={id}"></script>\n'
metatags += "<script>\n"
metatags += " window.dataLayer = window.dataLayer || [];\n"
metatags += " function gtag(){dataLayer.push(arguments);}\n"
metatags += " gtag('js', new Date());\n"
metatags += f" gtag('config', '{id}');\n"
metatags += "</script>\n"
context['metatags'] = metatags


def check_config(app):
if not app.config.googleanalytics_id:
raise ExtensionError("'googleanalytics_id' config value must be set for ga statistics to function properly.")


def setup(app):
app.add_config_value('googleanalytics_id', '', 'html')
app.add_config_value('googleanalytics_enabled', True, 'html')
app.connect('html-page-context', add_ga_javascript)
app.connect('builder-inited', check_config)
return {'version': '0.1'}
21 changes: 21 additions & 0 deletions docs/source/_ext/sphinx_accordion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


```
extensions = [
...
'sphinx_accordion.accordion'
...
]
```

```
.. accordion::
.. accordion-row:: The Title
The Contents
.. accordion-row:: The Second Title
The Contents 2
```
Empty file.
11 changes: 11 additions & 0 deletions docs/source/_ext/sphinx_accordion/accordion.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.sphinx-accordion.accordion {
margin-bottom: 1.75em;
}

.sphinx-accordion.title p {
display: inline-block;
margin-top: 8px;
margin-right: 0px;
margin-bottom: 8px;
margin-left: 0px;
}
46 changes: 46 additions & 0 deletions docs/source/_ext/sphinx_accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// if (!String.prototype.startsWith) {
// Object.defineProperty(String.prototype, 'startsWith', {
// value: function(search, pos) {
// pos = !pos || pos < 0 ? 0 : +pos;
// return this.substring(pos, pos + search.length) === search;
// }
// });
// }

$(document).ready(function(){console.log('FFS')});

$(function() {
console.log('SOMETHING HAPPENS MAYBE');

// We store the data-row values as sphinx-data-<data-row value>
// Add data-row attribute with the extracted value
$('.sphinx-accordion.title').each(function() {
const this1 = $(this);
const prefix = 'sphinx-accordion-title-';
const classes = this1.attr('class').split(/\s+/);
$.each(classes, function(idx, clazz) {
if (clazz.startsWith(prefix)) {
this1.attr('data-row', clazz.substring(prefix.length));
}
});

const data_row = this1.attr('data-row');

this1.on('click', function() {
// Find offset in view
const offset = (this1.offset().top - $(window).scrollTop());

// Toggle active class on this subsequent sibling
if (this1.hasClass('active')) {
this1.removeClass('active');
this1.next().removeClass('active');
} else {
this1.addClass('active');
this1.next().addClass('active');
}

// Keep tab with the original view offset
$(window).scrollTop(this1.offset().top - offset);
});
});
});
Loading

0 comments on commit f912c89

Please sign in to comment.