Skip to content

Commit 4cf1931

Browse files
author
Yunuuuu
committed
docs: initialize pkgdown site
1 parent 1a84b6d commit 4cf1931

28 files changed

+1068
-2
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ README.html
1111
^data-raw$
1212
^codecov\.yml$
1313
^revdep$
14+
^_pkgdown\.yml$
15+
^docs$
16+
^pkgdown$

.github/workflows/pkgdown.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
name: pkgdown.yaml
12+
13+
permissions: read-all
14+
15+
jobs:
16+
pkgdown:
17+
runs-on: ubuntu-latest
18+
# Only restrict concurrency for non-PR jobs
19+
concurrency:
20+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
21+
env:
22+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23+
permissions:
24+
contents: write
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: r-lib/actions/setup-pandoc@v2
29+
30+
- uses: r-lib/actions/setup-r@v2
31+
with:
32+
use-public-rspm: true
33+
34+
- uses: r-lib/actions/setup-r-dependencies@v2
35+
with:
36+
extra-packages: any::pkgdown, local::.
37+
needs: website
38+
39+
- name: Build site
40+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
41+
shell: Rscript {0}
42+
43+
- name: Deploy to GitHub pages 🚀
44+
if: github.event_name != 'pull_request'
45+
uses: JamesIves/github-pages-deploy-action@v4.5.0
46+
with:
47+
clean: false
48+
branch: gh-pages
49+
folder: docs

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
Scratch.RConsole
44

55
/.quarto/
6-
README.html
6+
README.html
7+
docs

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ Config/testthat/edition: 3
3535
Encoding: UTF-8
3636
Roxygen: list(markdown = TRUE)
3737
RoxygenNote: 7.3.2
38-
URL: https://github.com/WangLabCSU/blit
38+
URL: https://github.com/WangLabCSU/blit, https://wanglabcsu.github.io/blit/
3939
BugReports: https://github.com/WangLabCSU/blit/issues

_pkgdown.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
url: https://wanglabcsu.github.io/blit/
2+
template:
3+
bootstrap: 5
4+

docs/apple-touch-icon.png

11.1 KB
Loading

docs/bootstrap-toc.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*!
2+
* Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3+
* Copyright 2015 Aidan Feldman
4+
* Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5+
6+
/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */
7+
8+
/* All levels of nav */
9+
nav[data-toggle='toc'] .nav > li > a {
10+
display: block;
11+
padding: 4px 20px;
12+
font-size: 13px;
13+
font-weight: 500;
14+
color: #767676;
15+
}
16+
nav[data-toggle='toc'] .nav > li > a:hover,
17+
nav[data-toggle='toc'] .nav > li > a:focus {
18+
padding-left: 19px;
19+
color: #563d7c;
20+
text-decoration: none;
21+
background-color: transparent;
22+
border-left: 1px solid #563d7c;
23+
}
24+
nav[data-toggle='toc'] .nav > .active > a,
25+
nav[data-toggle='toc'] .nav > .active:hover > a,
26+
nav[data-toggle='toc'] .nav > .active:focus > a {
27+
padding-left: 18px;
28+
font-weight: bold;
29+
color: #563d7c;
30+
background-color: transparent;
31+
border-left: 2px solid #563d7c;
32+
}
33+
34+
/* Nav: second level (shown on .active) */
35+
nav[data-toggle='toc'] .nav .nav {
36+
display: none; /* Hide by default, but at >768px, show it */
37+
padding-bottom: 10px;
38+
}
39+
nav[data-toggle='toc'] .nav .nav > li > a {
40+
padding-top: 1px;
41+
padding-bottom: 1px;
42+
padding-left: 30px;
43+
font-size: 12px;
44+
font-weight: normal;
45+
}
46+
nav[data-toggle='toc'] .nav .nav > li > a:hover,
47+
nav[data-toggle='toc'] .nav .nav > li > a:focus {
48+
padding-left: 29px;
49+
}
50+
nav[data-toggle='toc'] .nav .nav > .active > a,
51+
nav[data-toggle='toc'] .nav .nav > .active:hover > a,
52+
nav[data-toggle='toc'] .nav .nav > .active:focus > a {
53+
padding-left: 28px;
54+
font-weight: 500;
55+
}
56+
57+
/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */
58+
nav[data-toggle='toc'] .nav > .active > ul {
59+
display: block;
60+
}

docs/bootstrap-toc.js

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*!
2+
* Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3+
* Copyright 2015 Aidan Feldman
4+
* Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5+
(function() {
6+
'use strict';
7+
8+
window.Toc = {
9+
helpers: {
10+
// return all matching elements in the set, or their descendants
11+
findOrFilter: function($el, selector) {
12+
// http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/
13+
// http://stackoverflow.com/a/12731439/358804
14+
var $descendants = $el.find(selector);
15+
return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])');
16+
},
17+
18+
generateUniqueIdBase: function(el) {
19+
var text = $(el).text();
20+
var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-');
21+
return anchor || el.tagName.toLowerCase();
22+
},
23+
24+
generateUniqueId: function(el) {
25+
var anchorBase = this.generateUniqueIdBase(el);
26+
for (var i = 0; ; i++) {
27+
var anchor = anchorBase;
28+
if (i > 0) {
29+
// add suffix
30+
anchor += '-' + i;
31+
}
32+
// check if ID already exists
33+
if (!document.getElementById(anchor)) {
34+
return anchor;
35+
}
36+
}
37+
},
38+
39+
generateAnchor: function(el) {
40+
if (el.id) {
41+
return el.id;
42+
} else {
43+
var anchor = this.generateUniqueId(el);
44+
el.id = anchor;
45+
return anchor;
46+
}
47+
},
48+
49+
createNavList: function() {
50+
return $('<ul class="nav"></ul>');
51+
},
52+
53+
createChildNavList: function($parent) {
54+
var $childList = this.createNavList();
55+
$parent.append($childList);
56+
return $childList;
57+
},
58+
59+
generateNavEl: function(anchor, text) {
60+
var $a = $('<a></a>');
61+
$a.attr('href', '#' + anchor);
62+
$a.text(text);
63+
var $li = $('<li></li>');
64+
$li.append($a);
65+
return $li;
66+
},
67+
68+
generateNavItem: function(headingEl) {
69+
var anchor = this.generateAnchor(headingEl);
70+
var $heading = $(headingEl);
71+
var text = $heading.data('toc-text') || $heading.text();
72+
return this.generateNavEl(anchor, text);
73+
},
74+
75+
// Find the first heading level (`<h1>`, then `<h2>`, etc.) that has more than one element. Defaults to 1 (for `<h1>`).
76+
getTopLevel: function($scope) {
77+
for (var i = 1; i <= 6; i++) {
78+
var $headings = this.findOrFilter($scope, 'h' + i);
79+
if ($headings.length > 1) {
80+
return i;
81+
}
82+
}
83+
84+
return 1;
85+
},
86+
87+
// returns the elements for the top level, and the next below it
88+
getHeadings: function($scope, topLevel) {
89+
var topSelector = 'h' + topLevel;
90+
91+
var secondaryLevel = topLevel + 1;
92+
var secondarySelector = 'h' + secondaryLevel;
93+
94+
return this.findOrFilter($scope, topSelector + ',' + secondarySelector);
95+
},
96+
97+
getNavLevel: function(el) {
98+
return parseInt(el.tagName.charAt(1), 10);
99+
},
100+
101+
populateNav: function($topContext, topLevel, $headings) {
102+
var $context = $topContext;
103+
var $prevNav;
104+
105+
var helpers = this;
106+
$headings.each(function(i, el) {
107+
var $newNav = helpers.generateNavItem(el);
108+
var navLevel = helpers.getNavLevel(el);
109+
110+
// determine the proper $context
111+
if (navLevel === topLevel) {
112+
// use top level
113+
$context = $topContext;
114+
} else if ($prevNav && $context === $topContext) {
115+
// create a new level of the tree and switch to it
116+
$context = helpers.createChildNavList($prevNav);
117+
} // else use the current $context
118+
119+
$context.append($newNav);
120+
121+
$prevNav = $newNav;
122+
});
123+
},
124+
125+
parseOps: function(arg) {
126+
var opts;
127+
if (arg.jquery) {
128+
opts = {
129+
$nav: arg
130+
};
131+
} else {
132+
opts = arg;
133+
}
134+
opts.$scope = opts.$scope || $(document.body);
135+
return opts;
136+
}
137+
},
138+
139+
// accepts a jQuery object, or an options object
140+
init: function(opts) {
141+
opts = this.helpers.parseOps(opts);
142+
143+
// ensure that the data attribute is in place for styling
144+
opts.$nav.attr('data-toggle', 'toc');
145+
146+
var $topContext = this.helpers.createChildNavList(opts.$nav);
147+
var topLevel = this.helpers.getTopLevel(opts.$scope);
148+
var $headings = this.helpers.getHeadings(opts.$scope, topLevel);
149+
this.helpers.populateNav($topContext, topLevel, $headings);
150+
}
151+
};
152+
153+
$(function() {
154+
$('nav[data-toggle="toc"]').each(function(i, el) {
155+
var $nav = $(el);
156+
Toc.init($nav);
157+
});
158+
});
159+
})();

0 commit comments

Comments
 (0)