Commit Graph

19 Commits

Author SHA1 Message Date
Nils Lindemann
ce85b819ff Prevent font flashing in the docs (#23622)
... by moving the Google font includes near the top of the head. By
including them as early as possible, they are known, when the browser
starts rendering the body.

Test it by making the change manually in `doc/html/system.html` and then
press ctrl+f5 (reload without cache). This removes the font flashing.

Tested in Chrome and Firefox.
2024-05-27 11:00:25 +02:00
Jake Leahy
1855f67503 Make data-theme default to "auto" in HTML (#23222)
Makes docs default to using browser settings instead of light mode

This should fix #16515 since it doesn't require the browser to run the
JS to set the default

Also means that dark mode can be used without JS if the browser is
configured to default to dark mode
2024-01-19 21:04:30 +08:00
Hamid Bluri
a26ccb3476 fix #22492 (#22511)
* fix #22492

* Update nimdoc.css

remove scroll-y

* Update nimdoc.out.css

* Update nimdoc.css

* make it sticky again

* Update nimdoc.out.css

* danm sticky, use fixed

* Update nimdoc.out.css

* fix margin

* Update nimdoc.out.css

* make search input react to any change (not just keyboard events) according to https://github.com/nim-lang/Nim/pull/22511#issuecomment-1685218787
2023-08-22 18:31:21 +02:00
Jake Leahy
753868f16c Fix #14476 (#20878)
* Use link from webpage. Closes #14476

* Update doc generation tests

* Update RST test
2022-11-21 14:59:06 -05:00
ringabout
7394587217 move google fonts to the last part (#20541)
* move google fonts to the last part

* fixes tests

* fix rst2html
2022-10-11 19:42:02 +02:00
Amjad Ben Hedhili
70a8e0d65c Docs auto dark mode (#20188)
* Implement auto dark mode

* Rename class

* Fix borders cutout

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-08-21 16:56:12 -04:00
Jake Leahy
dd4cc266cd Fixes #19900 (#19906)
Fixed tocRoot placement
2022-06-19 07:36:33 +02:00
JJ
e7e8f437c4 Keep the doc sidebar on the screen while scrolling (#19851)
* [docgen] Group sidebar sections into <details> (open by default)

* [docgen] Consistent indentation in generated HTML

(this is a boon for working on docgen's html/css output)

* [docgen] Move Source/Edit buttons inside main div

This makes styling the documentation significantly easier.

* [docgen] Somewhat consistent CSS formatting

* [docgen] Keep the sidebar onscreen while scrolling

* [docgen] Tweak CSS for the sticky sidebar

* [docgen] search type=text ==> type=search

* [docgen] Update expected doc output

* [docgen] Fix Group by Type sidebar placement bug

* [docgen] Curse you, whitespace (fix tests)

* [docgen] Fix rst2html tests

Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com>
2022-06-15 15:40:56 +02:00
flywind
ded8b0e541 rewrite docs JS in Nim (#19701)
* rewrite docs JS in Nim

* fixup

* fix nimdoc/rsttester
2022-04-09 17:50:57 +02:00
Andrey Makarov
0e44d137f9 rm redundant blank lines before literal blocks (#18465) 2021-07-08 20:24:57 -04:00
drtheuns
51ab7ccec1 Fix JS error on index page and detect dark mode (#18191)
* Fix JS error on index page and detect dark mode

The theindex.html page doesn't have a dark mode switch so the main
function will error because `toggleSwitch` is not defined. Checks have
been added to prevent this from happening.

Also add automatic detection of system settings for dark-mode. This
could also be done with pure css, but then the dark mode variable
declarations would have to be duplicated to work with the switch so I
went with this approach.

* Fix nimdoc tests

* Fix rst2html tests
2021-06-07 18:40:09 +02:00
Andrey Makarov
f8dce493d3 rst indentation fixes (ref #17340) (#17715) 2021-04-15 08:12:44 +02:00
Andrey Makarov
e35946f306 enable syntax highlighting for inline code (#17585)
* enable syntax highlighting for inline code

* finish '.. default-role' and preliminary '.. role'

implementation

* more compact check in dirRole

* set :literal: as default role for *.rst

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* use whichRole for setting currRoleKind

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* rename rnGeneralRole -> rnUnknownRole

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-04-02 22:11:44 +02:00
Timothee Cour
1590d14575 fix #17260 render \ properly in nim doc, rst2html (#17315) 2021-03-24 10:58:29 +01:00
Andrey Makarov
5984f7a7dd RST: improve line blocks (#16518) 2020-12-31 11:20:04 +01:00
Andrey Makarov
e843492b13 doc/rst2html: some few fixes for enumerated and bullet lists (#16295)
* fix bullet/enumarated lists with many blank lines
* fix enumerated list parsing
* fix parse failure when next line after list empty
* implement arbitrary start of enumerator
* check that enumerators are in order
* remove redundant start=x if x=1 or a
* add some doc on implemented features
* update start in rst_examples.rst
* allow upper-case letters + more docs
2020-12-14 18:10:39 +01:00
Sebastian Reinhard
93b6fac468 nimdoc: Initialize theme switch and pragma dots on DOMContentLoaded (#16247)
The default HTML template for nimdoc currently initializes the dark mode switch and pragma dots when the onload event is fired. But since the onload event does not fire until all external resources (images, stylesheets, fonts, etc.) have been loaded, the light theme is shown for a brief moment before the document is fully loaded, and it switches to the dark theme. This is quite jarring, especially on slower internet connections. So let's instead initialize these things on the DOMContentLoaded event, which is fired right after the document has been parsed and the initial DOM structure is ready. This means that we now display the dark mode immediately, without having to wait for external resources to load first.

For reference, see:
- https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
- https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event

I have updated the snapshot tests in `nimdoc/`, and done some manual testing of both the theme switch and the pragma dots, to confirm that this does not break anything. Please let me know if I've missed anything.
2020-12-06 10:13:19 +01:00
Andrey Makarov
6877e0c8a3 RST tables: fix latex col number; allow less than three of = (#16040) 2020-12-04 08:50:17 +01:00
Miran
d0c4c738b9 add a tester for rst2html (#15936) 2020-11-12 22:25:23 +01:00