Commit Graph

745 Commits

Author SHA1 Message Date
Juan M Gómez
642136ec4f Adds an extra optional argument to vcc: vctoolset Fixes #21335 (#21336) 2023-02-09 16:19:05 -05:00
Andrey Makarov
2620da9bf9 docgen: implement cross-document links (#20990)
* docgen: implement cross-document links

Fully implements https://github.com/nim-lang/RFCs/issues/125
Follow-up of: https://github.com/nim-lang/Nim/pull/18642 (for internal links)
and https://github.com/nim-lang/Nim/issues/20127.

Overview
--------

Explicit import-like directive is required, called `.. importdoc::`.
(the syntax is % RST, Markdown will use it for a while).

Then one can reference any symbols/headings/anchors, as if they
were in the local file (but they will be prefixed with a module name
or markup document in link text).
It's possible to reference anything from anywhere (any direction
in `.nim`/`.md`/`.rst` files).

See `doc/docgen.md` for full description.

Working is based on `.idx` files, hence one needs to generate
all `.idx` beforehand. A dedicated option `--index:only` is introduced
(and a separate stage for `--index:only` is added to `kochdocs.nim`).

Performance note
----------------

Full run for `./koch docs` now takes 185% of the time before this PR.
(After: 315 s, before: 170 s on my PC).
All the time seems to be spent on `--index:only` run, which takes
almost as much (85%) of normal doc run -- it seems that most time
is spent on file parsing, turning off HTML generation phase has not
helped much.
(One could avoid it by specifying list of files that can be referenced
and pre-processing only them. But it can become error-prone and I assume
that these linke will be **everywhere** in the repository anyway,
especially considering https://github.com/nim-lang/RFCs/issues/478.
So every `.nim`/`.md` file is processed for `.idx` first).

But that's all without significant part of repository converted to
cross-module auto links. To estimate impact I checked the time for
`doc`ing a few files (after all indexes have been generated), and
everywhere difference was **negligible**.
E.g. for `lib/std/private/osfiles.nim` that `importdoc`s large
`os.idx` and hence should have been a case with relatively large
performance impact, but:

* After: 0.59 s.
* Before: 0.59 s.

So Nim compiler works so slow that doc part basically does not matter :-)

Testing
-------

1) added `extlinks` test to `nimdoc/`
2) checked that `theindex.html` is still correct
2) fixed broken auto-links for modules that were derived from `os.nim`
   by adding appropriate ``importdoc``

Implementation note
-------------------

Parsing and formating of `.idx` entries is moved into a dedicated
`rstidx.nim` module from `rstgen.nim`.

`.idx` file format changed:

* fields are not escaped in most cases because we need original
  strings for referencing, not HTML ones
  (the exception is linkTitle for titles and headings).
  Escaping happens later -- on the stage of `rstgen` buildIndex, etc.
* all lines have fixed number of columns 6
* added discriminator tag as a first column,
  it always allows distinguish Nim/markup entries, titles/headings, etc.
  `rstgen` does not rely any more (in most cases) on ad-hoc logic
  to determine what type each entry is.
* there is now always a title entry added at the first line.
* add a line number as 6th column
* linkTitle (4th) column has a different format: before it was like
  `module: funcName()`, now it's `proc funcName()`.
  (This format is also propagated to `theindex.html` and search results,
  I kept it that way since I like it more though it's discussible.)
  This column is what used for Nim symbols resolution.
* also changed details on column format for headings and titles:
  "keyword" is original, "linkTitle" is HTML one

* fix paths on Windows + more clear code

* Update compiler/docgen.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

* Handle .md and .nim paths uniformly in findRefFile

* handle titles better + more comments

* don't allow markup overwrite index title for .nim files

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-01-04 15:19:01 -05:00
ringabout
646932b3f3 fixes warnings when building csources (#21194)
* replace `symbolfiles` with `incremental`; fixes warnings when build csources

* fixes self conversion warnings
2022-12-28 20:41:27 +01:00
Andreas Rumpf
82d80e6e2c atlas: minor doc improvements (#21183)
* closes #20808

* atlas: better docs
2022-12-27 14:30:26 +01:00
Jake Leahy
86a6c90c9e Make search results be relative to documentation root (#21145)
Use Nim instead of JS for searching
2022-12-23 13:20:51 -05:00
Luca Guzzon
8a77798dac ucpu fix-up for arm64 value on macos m1 (#21142) 2022-12-20 20:29:42 +01:00
ringabout
8a3b76b287 csource building prefers bin/nim (#21115) 2022-12-16 07:59:18 +01:00
ringabout
9ba07edb2e build the documentation of official packages (#20986)
* remove db stuffs

* remove punycode

* remove

* fixes script

* add cloner

* patches

* disable

* patch

* fixes external packages

* disable two packages

* preview documentation build

* try again

* fixes URL

* fixes a bug

* simplify

* fixes documentaion

* fixes

* Apply suggestions from code review
2022-12-06 22:37:16 +08:00
Federico Ceratto
b36f5119ae Add HPPA and sparc64 architectures (#20934)
* Add comments on CPU arch detection

* Support HPPA/hppa/parisc64 CPU architecture

* Support sparc64 CPU architecture

* Update tools/niminst/makefile.nimf

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2022-12-01 12:48:47 +08:00
Federico Ceratto
8a68ed65d0 Support IBM Z architecture (#20943) 2022-11-28 13:33:09 -05:00
Federico Ceratto
f644f04654 Handle ppc CPU architecture (#20920)
* Remove confusing "ppc" block

The PowerPC arch is called "powerpc" in platforms.nim

The makefile shipped in release 1.6.10 populates the oFiles variable when myos=linux and mycpu=powerpc
mycpu=ppc instead leads to  ``no C code generated for: [linux: ppc].  Stop``

* Handle ucpu=ppc
2022-11-26 21:59:52 +01:00
Juan Carlos
2709898a5e koch remove dead code (#20912)
* koch remove dead code for Travis CI

* Restart CI

* Restart CI
2022-11-25 13:51:11 +01: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
0a1f204f0f removes channels_builtin when enabling nimPreviewSlimSystem (#20713) 2022-10-31 16:56:05 +08:00
ringabout
1dab8ba334 move threads out of system (#20674)
* move syslocks first

* progress

* clean up

* go on

* clean up

* clean up

* add imports syslocks

* remove documentation

* public deallocOsPages

* fixes genode

* fixes more

* fixes boehmGC

* cover more cases

* fixes cyclic deps

* fixes genode

* cleanup

* unpublic fields

* cleanup

* clean up
2022-10-29 18:11:40 +02:00
Andrey Makarov
779b1cc5be Fix #20628 for Windows (#20667)
* Fix #20628 for Windows

* Move isRegular - !isSpecial and onlyRegular - skipSpecial

* Forgot to change it in 1 more place
2022-10-28 10:01:28 +02:00
Andrey Makarov
8ed2431db0 Implement Unix file regularity check (#20448) (#20628)
* Implement Unix file regularity check

* update std/dirs also
2022-10-25 07:42:47 +02:00
ringabout
15dff4daff fixes niminst with stricteffects; add testcase for niminst (#20587)
fixes niminst with stricteffects; add testcase
2022-10-18 08:59:02 +02:00
Andrey Makarov
b793ca7394 Validate nimgrep filter options not empty (#20562) 2022-10-14 00:44:34 -04:00
Andreas Rumpf
b8def03575 Atlas: added an explicit --workspace option (#20532) 2022-10-10 15:01:39 +02:00
Andreas Rumpf
0f2775aacf implemented 'atlas install' command (#20530) 2022-10-10 11:05:44 +02:00
metagn
0b1650576c move widestrs out of system (#20462)
* move widestrs out of system

* fix osproc
2022-10-01 22:35:09 +02:00
ringabout
96c5586d03 add plausibleAnalytics support for koch docs[backport:1.6] (#20454)
add plausibleAnalytics to koch docs[backport:1.6]
2022-09-30 12:39:28 +02:00
ringabout
3e43ea3384 make koch and tools work with nimPreviewSlimSystem (#20459) 2022-09-30 08:09:40 +08:00
metagn
919a889ba8 moderate system cleanup & refactor (#20355)
* system refactor, move out 600 lines

* compilation, slice, backwardsindex, misc_num moved out of system
* some procs/types moved into arithmetics, basic_types
* system no longer depends on syncio
* some procs moved around to fit with their surroundings

* make exceptions an import, old ops to misc_num

* move instantiationInfo back

* move back nim version, fix windows echo

* include compilation

* better docs for imported modules, fix unsigned ops

also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem

* fix terminal

* workaround IC test & weird csize bug, changelog

* move NimMajor etc back to compilation, rebase for CI

* try ic fix

* form single `indices`, slim out TaintedString, try fix IC

* fix CI, update changelog, addQuitProc

* fix CI

* try fix CI

* actually fix CI finally hopefully

* Update lib/system/compilation.nim

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>

* update kochdocs

* hopefully fix csize uses for slimsystem

* fix tquit

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-09-28 15:28:45 -04:00
ringabout
95614089ac remove deprecated and broken nimweb tools (#20442)
* remove deprecated and broken nimweb tools

* readme
2022-09-28 12:14:35 +02:00
Andrey Makarov
2140d05f34 nimgrep: add --inContext and --notinContext options (#19528)
* nimgrep: add `--matchContext` and `--noMatchContext` options

* Rename options for uniformity

* Revise option names, add `--parentPath` options

* Revert --bin deprecation

* Copy-paste an original test from quantimnot

The origin was:
96544656d5/tnimgrep.nim

* Change ! to n

* Attempt to fix test

* Fix test on Windows

* Change --contentsFile -> --inFile, add more tests

* Bump

* Change --parentPath to --dirpath
2022-09-14 18:28:01 +02:00
Amjad Ben Hedhili
b931e74a59 Cleanup dochack (#20299)
* Cleanup dochack

* xxx

* More cleanups
2022-09-04 01:38:38 -04:00
metagn
86f7f4ffa5 remove deprecated type pragma syntax, fix bugs that required it (#20199)
* remove deprecated pragma syntax from 0.20.0

closes #4651, closes #16653 with a cheap fix for now due to
how early `tfFinal` is set

* remove type pragma between name and generics

* undo removal, try removing bind expression (0.8.14)

* fix test, unremove bind expr

* remove again

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* dependencies @ HEAD & weave test dependencies

* try fix package ci

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2022-09-03 09:52:13 +02:00
Andrey Makarov
ee11302c24 fix nim md2tex and koch pdf commands (#20280)
* fix `nim md2tex` and `koch pdf` commands

* change rst2tex -> md2tex also
2022-08-28 18:04:13 -04: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
ringabout
c9c1c97f1e make sure tools/heapdumprepl.nim continues to compile (#20146) 2022-08-19 15:42:51 -04:00
ee7
e8657c7107 make implicit cstring conversions explicit (#19488)
The Nim manual says that an implicit conversion to cstring will
eventually not be allowed [1]:

    A Nim `string` is implicitly convertible to `cstring` for convenience.

    [...]

    Even though the conversion is implicit, it is not *safe*: The garbage collector
    does not consider a `cstring` to be a root and may collect the underlying
    memory. For this reason, the implicit conversion will be removed in future
    releases of the Nim compiler. Certain idioms like conversion of a `const` string
    to `cstring` are safe and will remain to be allowed.

And from Nim 1.6.0, such a conversion triggers a warning [2]:

    A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning.
    This warning will become an error in future versions! Use an explicit conversion
    like `cstring(x)` in order to silence the warning.

However, some files in this repo produced such a warning. For example,
before this commit, compiling `parsejson.nim` would produce:

    /foo/Nim/lib/pure/parsejson.nim(221, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]
    /foo/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]

This commit resolves the most visible `CStringConv` warnings, making the
cstring conversions explicit.

[1] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/doc/manual.md#cstring-type
[2] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/changelogs/changelog_1_6_0.md#type-system
2022-08-19 15:40:53 -04:00
Ivan Yonchovski
ec2bc2a50e Build compiler with --noNimblePath (#20168)
- Fixes https://github.com/nim-lang/Nim/issues/18840
2022-08-09 14:04:52 -04:00
Anna
2549d398a9 niminst: support DESTDIR and quote variables (#20051)
* niminst: support DESTDIR (fix #9788)

* niminst: quote variables
2022-07-18 21:22:53 +02:00
Andrey Makarov
417b90a7e5 Improve Markdown code blocks & start moving docs to Markdown style (#19954)
- add additional parameters parsing (other implementations will just
  ignore them). E.g. if in RST we have:

  .. code:: nim
     :test: "nim c $1"

     ...

  then in Markdown that will be:

  ```nim test="nim c $1"
  ...
  ```

- implement Markdown interpretation of additional indentation which is
  less than 4 spaces (>=4 spaces is a code block but it's not
implemented yet). RST interpretes it as quoted block, for Markdown it's
just normal paragraphs.
- add separate `md2html` and `md2tex` commands. This is to separate
  Markdown behavior in cases when it diverges w.r.t. RST significantly —
most conspicously like in the case of additional indentation above, and
also currently the contradicting inline rule of Markdown is also turned
on only in `md2html` and `md2tex`. **Rationale:** mixing Markdown and
RST arbitrarily is a way to nowhere, we need to provide a way to fix the
particular behavior. Note that still all commands have **both** Markdown
and RST features **enabled**. In this PR `*.nim` files can be processed
only in Markdown mode, while `md2html` is for `*.md` files and
`rst2html` for `*.rst` files.
- rename `*.rst` files to `.*md` as our current default behavior is
  already Markdown-ish
- convert code blocks in `docgen.rst` to Markdown style as an example.
  Other code blocks will be converted in the follow-up PRs
- fix indentation inside Markdown code blocks — additional indentation
  is preserved there
- allow more than 3 backticks open/close blocks (tildas \~ are still not
  allowed to avoid conflict with RST adornment headings) see also
https://github.com/nim-lang/RFCs/issues/355
- better error messages
- (other) fix a bug that admonitions cannot be used in sandbox mode; fix
  annoying warning on line 2711
2022-07-15 19:27:54 +02:00
Sam Zaydel
306810a748 Enable nim-lang to build correctly on illumos-based systems (#19952) 2022-06-30 23:16:50 +02:00
quantimnot
6f4bacff67 Extend and document compiler debugging utilities (#19841)
* Add two debugutils procs that native debuggers can break on use to
  execute commands when code of interest is being compiled.
* Add GDB and LLDB programs to disable and enable breakpoints and
  watchpoints when code of interest is being compiled.
* Extend the `intern.rst` docs regarding debugging the compiler.

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2022-06-10 20:40:08 +02:00
Yardanico
06f02bb771 Always use httpclient in nimgrab (#19767) 2022-05-17 09:56:39 +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
VlkrS
488e18f90d Fix CPU detection for i386 (#19577)
* Fix CPU detection for i386

Commit 787def271b breaks CPU detection for i386 on OpenBSD and probably on other platforms.
[ isOpenIndiana -eq "yes" ] always returns 0, so mycpu is always set to "amd64".

* Update buildsh.nimf

Fix accidental bashism
2022-03-03 14:41:35 +01:00
Juan Carlos
f0bfc0bd3f Remove define for jsfetch (#19530)
* Remove define nimExperimentalAsyncjsThen for std/asyncjs.then and std/jsfetch

* Remove define nimExperimentalAsyncjsThen for std/asyncjs.then and std/jsfetch

* Remove define nimExperimentalAsyncjsThen for std/asyncjs.then and std/jsfetch

* Remove define nimExperimentalAsyncjsThen for std/asyncjs.then and std/jsfetch
2022-02-25 20:34:16 +01:00
flywind
891329cd4b move io out of system (#19442)
* move io out of system

* fix tests

* fix tests

* next step

* rename to syncio

* rename

* fix nimscript

* comma

* fix

* fix parts of errors

* good for now

* fix test
2022-02-02 17:10:11 +01:00
Andrey Makarov
d7869a8009 Improve Zshell completion (#19354) 2022-01-18 15:58:18 -05:00
pkubaj
7a5314c571 Fix build on FreeBSD/powerpc (#19282)
It's currently misdetected as powerpc64.
2021-12-22 20:52:33 -05:00
snxx
609388e33f Add icon for Nim (#19258)
* Add Nim's file icon

* Add installer icon

* Add uninstaller icon
2021-12-17 08:58:05 +01:00
wenghongquan
742e9d65ad Add support for LoongArch (#19223)
* Add support for LoongArch

* Update compiler/installer.ini

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-12-09 14:00:33 +01:00
Andreas Rumpf
a0073d2d4c renamed 'gc' switch to 'mm'; [backport:1.6] (#19187)
* renamed 'gc' switch to 'mm'; [backport:1.6]
* better docs
2021-11-24 15:49:32 +01:00
Andrey Makarov
997ccc5889 fix nimindexterm in rst2tex/doc2tex [backport] (#19106)
* fix nimindexterm (rst2tex/doc2tex) [backport]

* Add support for indexing in rst
2021-11-09 19:01:47 +01:00
Kaushal Modi
efaaa38eef docstyle.rst: Do not export it to HTML as a standalone doc (#19083)
.. This doc is included in contributing.rst.

Fixes https://github.com/nim-lang/Nim/issues/14593.
2021-11-02 10:34:11 +01:00