mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Merge branch 'master' into nav-sorting
This commit is contained in:
@@ -22,6 +22,54 @@ Just the Docs has some specific configuration parameters that can be defined in
|
||||
|
||||
View this site's [_config.yml](https://github.com/pmarsceill/just-the-docs/tree/master/_config.yml) file as an example.
|
||||
|
||||
## Document collections
|
||||
|
||||
By default, the navigation and search include normal [pages](https://jekyllrb.com/docs/pages/).
|
||||
Instead, you can also use [Jekyll collections](https://jekyllrb.com/docs/collections/) which group documents semantically together.
|
||||
|
||||
For example, put all your documentation files in the `_docs` folder and create the `docs` collection:
|
||||
```yaml
|
||||
# Define Jekyll collections
|
||||
collections:
|
||||
# Define a collection named "docs", its documents reside in the "_docs" directory
|
||||
docs:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
|
||||
just_the_docs:
|
||||
# Define which collections are used in just-the-docs
|
||||
collections:
|
||||
# Reference the "docs" collection
|
||||
docs:
|
||||
# Give the collection a name
|
||||
name: Documentation
|
||||
# Exclude the collection from the navigation
|
||||
# Supports true or false (default)
|
||||
nav_exclude: false
|
||||
# Exclude the collection from the search
|
||||
# Supports true or false (default)
|
||||
search_exclude: false
|
||||
```
|
||||
|
||||
You can reference multiple collections.
|
||||
This creates categories in the navigation with the configured names.
|
||||
```yaml
|
||||
collections:
|
||||
docs:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
tutorials:
|
||||
permalink: "/:collection/:path/"
|
||||
output: true
|
||||
|
||||
just_the_docs:
|
||||
collections:
|
||||
docs:
|
||||
name: Documentation
|
||||
tutorials:
|
||||
name: Tutorials
|
||||
```
|
||||
|
||||
## Site logo
|
||||
|
||||
```yaml
|
||||
|
@@ -39,7 +39,7 @@ GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
end
|
||||
```
|
||||
|
||||
#### [](#header-4)Header 4
|
||||
#### [](#header-4)Header 4 `with code not transformed`
|
||||
|
||||
* This is an unordered list following a header.
|
||||
* This is an unordered list following a header.
|
||||
@@ -140,6 +140,37 @@ end
|
||||
<dd>Green</dd>
|
||||
</dl>
|
||||
|
||||
#### Multiple description terms and values
|
||||
|
||||
Term
|
||||
: Brief description of Term
|
||||
|
||||
Longer Term
|
||||
: Longer description of Term,
|
||||
possibly more than one line
|
||||
|
||||
Term
|
||||
: First description of Term,
|
||||
possibly more than one line
|
||||
|
||||
: Second description of Term,
|
||||
possibly more than one line
|
||||
|
||||
Term1
|
||||
Term2
|
||||
: Single description of Term1 and Term2,
|
||||
possibly more than one line
|
||||
|
||||
Term1
|
||||
Term2
|
||||
: First description of Term1 and Term2,
|
||||
possibly more than one line
|
||||
|
||||
: Second description of Term1 and Term2,
|
||||
possibly more than one line
|
||||
|
||||
### More code
|
||||
|
||||
```
|
||||
Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.
|
||||
```
|
||||
|
@@ -2,6 +2,7 @@
|
||||
layout: default
|
||||
title: Code
|
||||
parent: UI Components
|
||||
has_children: true
|
||||
nav_order: 6
|
||||
---
|
||||
|
||||
|
124
docs/ui-components/linenos.md
Normal file
124
docs/ui-components/linenos.md
Normal file
@@ -0,0 +1,124 @@
|
||||
---
|
||||
layout: default
|
||||
title: Code with line numbers
|
||||
parent: Code
|
||||
grand_parent: UI Components
|
||||
---
|
||||
|
||||
# Configuration options
|
||||
|
||||
The default settings for HTML compression are incompatible with the HTML
|
||||
produced by Jekyll (4.1.1 or earlier) for line numbers from highlighted code
|
||||
-- both when using Kramdown code fences and when using Liquid highlight tags.
|
||||
|
||||
To avoid non-conforming HTML and unsatisfactory layout, HTML compression
|
||||
can be turned off by using the following configuration option:
|
||||
|
||||
{% highlight yaml %}
|
||||
compress_html:
|
||||
ignore:
|
||||
envs: all
|
||||
{% endhighlight %}
|
||||
|
||||
When using Kramdown code fences, line numbers are turned on globally by the
|
||||
following configuration option:
|
||||
|
||||
{% highlight yaml %}
|
||||
kramdown:
|
||||
syntax_highlighter_opts:
|
||||
block:
|
||||
line_numbers: false
|
||||
{% endhighlight %}
|
||||
|
||||
Line numbers can then be suppressed locally using Liquid tags (_without_ the
|
||||
`linenos` option) instead of fences:
|
||||
|
||||
{% highlight yaml %}
|
||||
{% raw %}{% highlight some_language %}
|
||||
Some code
|
||||
{% endhighlight %}{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
# Workarounds
|
||||
|
||||
To use HTML compression together with line numbers, all highlighted code
|
||||
needs to be wrapped using one of the following workarounds.
|
||||
(The variable name `some_var` can be changed to avoid clashes; it can also
|
||||
be replaced by `code` -- but note that `code=code` cannot be removed).
|
||||
|
||||
## Code fences
|
||||
|
||||
{% highlight default %}
|
||||
{% raw %}{% capture some_var %}
|
||||
```some_language
|
||||
Some code
|
||||
```
|
||||
{% endcapture %}
|
||||
{% assign some_var = some_var | markdownify %}
|
||||
{% include fix_linenos.html code=some_var %}{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
## Liquid highlighting
|
||||
|
||||
{% highlight default %}
|
||||
{% raw %}{% capture some_var %}
|
||||
{% highlight some_language linenos %}
|
||||
Some code
|
||||
{% endhighlight %}
|
||||
{% endcapture %}
|
||||
{% include fix_linenos.html code=some_var %}{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
_Credit:_ The original version of the above workaround was suggested by
|
||||
Dmitry Hrabrov at
|
||||
<https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901>.
|
||||
|
||||
# Examples
|
||||
|
||||
```
|
||||
Some unknown code in fences
|
||||
```
|
||||
|
||||
```js
|
||||
// Javascript code with syntax highlighting in fences
|
||||
var fun = function lang(l) {
|
||||
dateformat.i18n = require('./lang/' + l)
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby code with syntax highlighting in fences
|
||||
GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
s.add_dependency(gem, "= #{version}")
|
||||
end
|
||||
```
|
||||
|
||||
{% highlight ruby %}
|
||||
# Ruby code with syntax highlighting using Liquid
|
||||
GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
s.add_dependency(gem, "= #{version}")
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
||||
{% capture code %}
|
||||
{% highlight ruby linenos %}
|
||||
# Ruby code with syntax highlighting and fixed line numbers using Liquid
|
||||
GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
s.add_dependency(gem, "= #{version}")
|
||||
end
|
||||
{% endhighlight %}
|
||||
{% endcapture %}
|
||||
{% include fix_linenos.html code=code %}
|
||||
{% assign code = nil %}
|
||||
|
||||
With the default configuration options, the following example illustrates
|
||||
the incorrect formatting arising from the incompatibility of HTML compression
|
||||
and the non-conforming HTML produced by Jekyll for line numbers:
|
||||
|
||||
{% highlight ruby linenos %}
|
||||
# Ruby code with syntax highlighting and unfixed line numbers using Liquid
|
||||
GitHubPages::Dependencies.gems.each do |gem, version|
|
||||
s.add_dependency(gem, "= #{version}")
|
||||
end
|
||||
{% endhighlight %}
|
@@ -21,7 +21,7 @@ nav_order: 1
|
||||
By default, Just the Docs uses a native system font stack for sans-serif fonts:
|
||||
|
||||
```scss
|
||||
-apple-system, BlinkMacSystemFont, "helvetica neue", helvetica, roboto, noto, "segoe ui", arial, sans-serif
|
||||
system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
|
||||
```
|
||||
|
||||
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
|
Reference in New Issue
Block a user