summary refs log tree commit diff stats
path: root/compiler/docgen.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #23914; jsondoc broken in devel (#23916)ringabout2024-08-111-1/+1
| | | | | follows up https://github.com/nim-lang/Nim/pull/23064 fixes #23914
* retain postfix node in type section typed AST, with docgen fix (#23101)metagn2023-12-231-13/+18
| | | | | | Continued from #23096 which was reverted due to breaking a package and failing docgen tests. Docgen should now work, but ~~a PR is still pending for the package: https://github.com/SciNim/Unchained/pull/45~~ has been merged
* fixes yet another strictdefs bug (#23069)ringabout2023-12-151-4/+6
|
* fixes #23051; don't generate documentation for exported symbols again (#23074)ringabout2023-12-141-1/+2
| | | | | | | | | | | | | fixes #23051 Before ![image](https://github.com/nim-lang/Nim/assets/43030857/d402a837-281e-4035-8302-500f64dccdb5) After ![image](https://github.com/nim-lang/Nim/assets/43030857/de9a23f1-9e50-4551-b3fd-3311e1de378e)
* type graph refactor; part 3 (#23064)Andreas Rumpf2023-12-141-2/+1
|
* Fix using `--stdout` with `jsondoc` (#22925)Jake Leahy2023-11-091-1/+1
| | | | | | | | | | | Fixes the assertion defect that happens when using `jsondoc --stdout` (There is no outfile since its just stdout) ``` Error: unhandled exception: options.nim(732, 3) `not conf.outFile.isEmpty` [AssertionDefect] ``` Also makes the output easier to parse by ending each module output with a new line.
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-5/+6
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-2/+2
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-1/+1
|
* replaces `doAssert false` with `raiseAssert` for unreachable branches, which ↵ringabout2023-08-101-3/+2
| | | | | works better with strictdefs (#22436) replaces `doAssert false` with `raiseAssert`, which works better with strictdefs
* refactors initSrcGen and initTokRender into returning objects (#22421)ringabout2023-08-091-8/+5
|
* use strictdefs for compiler (#22365)ringabout2023-08-061-13/+33
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fix server caching issue causing Theme failures (#22378)Daniel Belmes2023-08-061-2/+2
| | | | | | | | | * fix server caching issue causing Theme failures * Fix tester to ignore version cache param * fix case of people using -d:nimTestsNimdocFixup * rsttester needed the same fix
* Fix doc comment rendering for concepts (#22312)konsumlamm2023-07-221-1/+1
|
* fix `jsondoc` not getting `showNonExports` flag (#22267)Jake Leahy2023-07-201-7/+10
| | | Pass the config down so we can check if the `--showNonExports` flag is used
* Tolerate markup errors for doc comments (#19607) (#22235)Andrey Makarov2023-07-071-3/+13
| | | | | | | | | | | | | | | | | Follow-up to #21576 (for solving #19607). 1) errors in Markdown mode for `.nim` doc comments are reported with red color but allow to generate `.html` with the comment represented by literate block (monospaced text). We suppose that it's what people want for (supposedly) small doc comments. And this behavior is also a bit more Markdown-ish in the sense that Markdown generally does not have the concept of parsing error. - However, for standalone `.md` it's **not** applied because for large files the consequences are way bigger. (In {.doctype: rst.} mode the behavior is the same as before -- report the error and stop.) In future, when our parser can handle Markdown without errors according to the spec, this code will most probably be not needed.
* fixes #19607 (#21576)Andreas Rumpf2023-06-161-11/+17
|
* compiler/docgen: pass --path:… to runnableExamples (#21669)Emery Hemingway2023-04-171-2/+5
|
* runnableExamples imports std/assertions by default (#21658)metagn2023-04-141-1/+3
| | | closes https://github.com/nim-lang/RFCs/issues/499
* Fix nim doc crash with group referencing & include (#21600)Andrey Makarov2023-04-021-6/+11
| | | | | | | This fixes a regression introduced in #20990 . When a group referencing is used and one of the overloaded symbols is in `include`d file, then `nim doc` crashes. The fix is in distinguishing (the index of) module and file where the symbol is defined, and using only module as the key in hash table for group referencing.
* fixes #19396; Nimdoc hide nonexported fields (#21305)ringabout2023-02-011-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * suppresses non-exported fields of types and adds command-line option to re-enable this if desired * corrected the doctest that produced a CI error * an embarrassingly bad error in reasoning * modified a nimdoc test to reflect updated behavior * needed another change to bring utils.html doctest in sync with update * add info * fix nimdoc * lint * render postfix * fixes a problem * fixes nimdoc * fix nimdoc --------- Co-authored-by: johnperry-math <john.perry@usm.edu> Co-authored-by: johnperry-math <devotus@yahoo.com>
* docgen: implement cross-document links (#20990)Andrey Makarov2023-01-041-55/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* fix #19580; add warning for bare except: clause (#21099)ringabout2022-12-151-4/+4
| | | | | | | | | | | | | | | | | | | | | * fix #19580; add warning for bare except: clause * fixes some easy ones * Update doc/manual.md * fixes docs * Update changelog.md * addition * Apply suggestions from code review Co-authored-by: Jacek Sieka <arnetheduck@gmail.com> * Update doc/tut2.md Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
* Docs expand `using` parameters (#21076)Jake Leahy2022-12-121-4/+4
| | | | | | | | | | | | | | | * Trying to fix by changing renderer * add renderExpandUsing flag This flag makes the renderer expand parameters that use using statement to have their full type * Update docs * Make comment better explain why checking for nkSym * Fix nil access when macro/template has parameter with no type * Fix nil access when node is not semmed yet
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-121-1/+1
| | | | | | | | | (#21065) * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869
* Revert "fix #15836 proc arg return type auto unexpectly match proc with ↵ringabout2022-12-091-1/+1
| | | | | | | concr…" (#21057) Revert "fix #15836 proc arg return type auto unexpectly match proc with concr… (#21044)" This reverts commit 0cd9bdcf9f6802421e0d8e4c28fc732012af605e.
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-091-1/+1
| | | | | (#21044) fix #15836 proc arg return type auto unexpectly match proc with concrete type
* fixes #20572 (#20585)Andreas Rumpf2022-10-171-2/+2
| | | | | * fixes #20572 * added a test case
* Fix "imported but not used" warnings (#20575)Andrey Makarov2022-10-161-1/+0
|
* Make rstgen work with gcsafe (#20534)ringabout2022-10-101-3/+3
| | | | | | | | | | | * Make rstgen work with gcsafe Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * add tests and fixes * if nimHasWarningAsError Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com>
* add plausibleAnalytics support for koch docs[backport:1.6] (#20454)ringabout2022-09-301-0/+8
| | | add plausibleAnalytics to koch docs[backport:1.6]
* fixes #9462; jsondoc --index can generate a theindex.json (#20205)ringabout2022-09-061-0/+16
|
* fix `nim md2tex` and `koch pdf` commands (#20280)Andrey Makarov2022-08-281-1/+2
| | | | | * fix `nim md2tex` and `koch pdf` commands * change rst2tex -> md2tex also
* Fix auto links to subheader when TOC is present (#20279)Andrey Makarov2022-08-271-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix links to subheader when TOC is present It was observed (in https://github.com/nim-lang/Nim/pull/20112) that links to 2nd- (and subsequent) -level headings fail if TOC is present, e.g.: ```nim .. contents:: Type relations ============== Convertible relation -------------------- Ref. `Convertible relation`_ ``` The problem here is that links are resolved in `rst.nim` but later `rstgen.nim` fixes ("fixes") anchors to make them unique so that TOC always works (if e.g. there was another sub-section like "Convertible relation"). The solution implemented in this PR is to move that fix-up of anchors into `rst.nim`, so that link resolution could know final anchors. The bug seems to be added in https://github.com/nim-lang/Nim/pull/2332 in 2015, that is it is present in Nim 1.0.
* Add `doctype: RST|Markdown|RstMarkdown` pragma (#20252)Andrey Makarov2022-08-231-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | * Add `doctype: RST|Markdown|RstMarkdown` pragma Implements https://github.com/nim-lang/RFCs/issues/68 , see also discussion in https://github.com/nim-lang/Nim/issues/17987 The permitted values: * `markdown`, which is default. It still contains nearly all of the RST supported but it is assumed that in time we will give up most or all RST features in this mode * `rst`, without any extensions * `RstMarkdown` — compatibility with Nim 1.x. It's basically RST with those Markdown features enabled that don't conflict with RST. * Apply suggestions from code review Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Additional fix in spirit of review * Fix test after #20188 Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* fixes #11953; jsondoc creates no files unless the htmldocs dir is created ↵ringabout2022-08-201-0/+2
| | | | | | | | | (#20198) * fixes #11953; jsondoc creates no files unless the htmldocs dir is created * target * fixes runner
* bootstrap the compiler with nimPreviewSlimSystem (#20176)ringabout2022-08-091-0/+4
| | | | | * bootstrap the compiler with nimPreviewSlimSystem * threads
* fixes #20132; fixes the broken jsondoc comand [backport] (#20135)ringabout2022-08-041-1/+2
| | | | | * fixes #20132; fixes the broken jsondoc comand * add testcase
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Make imports/exports not be a dropdown in sidebar (#19907)Jake Leahy2022-07-161-3/+14
| | | | | | | | | * Don't make a section be a dropdown if it has no child links * - Cleaned up code - Updated tests * Document what the 'if' is checking
* Improve Markdown code blocks & start moving docs to Markdown style (#19954)Andrey Makarov2022-07-151-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* RST: improve simple tables (#19859)Andrey Makarov2022-06-041-0/+1
| | | | | | | * RST: improve simple tables * nim 1.0 gotchas * Still allow legacy boundaries like `----`
* Refactor and doc package handling, module name mangling (#19821)quantimnot2022-05-301-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor and doc package handling, module name mangling * Consolidate, de-duplicate and extend package handling * Alter how duplicate module names of a package are handled * Alter how module names are mangled * Fix crash when another package is named 'stdlib' (test case added) * Doc what defines a package in the manual Modules with duplicate names within a package used to be given 'fake' packages to resolve conflicts. That prevented the ability to discern if a module belonged to the current project package or a foreign package. They now have the proper package owner and the names are mangled in a consistent manner to prevent codegen clashes. All module names are now mangled the same. Stdlib was treated special before, but now it is same as any other package. This fixes a crash when a foreign package is named 'stdlib'. Module mangling is altered for both file paths and symbols used by the backends. Removed an unused module name to package mapping that may have been intended for IC. The mapping was removed because it wasn't being used and was complicating the issue of package modules with duplicate names not having the proper package owner assigned. * Fix some tests * Refactor `packagehandling` * Remove `packagehandling.withPackageName` and its uses * Move module path mangling from `packagehandling` to `modulepaths` * Move `options.toRodFile` to `ic` to break import cycle * Changed import style to match preferred style Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* Move common Latex code into class nimdoc.cls (#19734)Andrey Makarov2022-04-211-1/+5
|
* Document links repect --out in .idx file (#19543)Jake Leahy2022-02-241-1/+4
| | | | | | | * Link in .idx file now respects --out:file switch * Use clearer chained calls Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* fix broken CI (#19472)flywind2022-01-311-0/+1
| | | | | | | * fix broken CI * fix * fix tests
* Merge pull request from GHSA-ggrq-h43f-3w7mDominik Picheta2022-01-291-1/+1
| | | | This fixes a CVE (currently https://github.com/nim-lang/Nim/security/advisories/GHSA-ggrq-h43f-3w7m)
* Fix group reference (with capital letters (#19196)Andrey Makarov2021-12-201-1/+2
| | | in group name)
* change os.nim doc links to new style (#19102)Andrey Makarov2021-11-081-0/+7
|
* docgen: implement doc link resolution in current module (#18642)Andrey Makarov2021-10-281-16/+138
|