3
0
Fork 0
forked from mirrors/nixpkgs
Commit graph

263 commits

Author SHA1 Message Date
pennae c8b4e5d557
Merge pull request #237557 from pennae/dedocbookify-nixos
nixos/doc: dedocbookify
2023-06-19 14:05:03 +02:00
Victor Engmark 7b396875bb nixos-render-docs: De-lint using ruff --fix
This automated de-linting has applied a few different refactors:

- Remove unused imports and variables
- Change f-strings with no variables to regular strings
- Remove trailing semicolon
2023-06-14 14:39:00 +12:00
pennae 34eeac5544 nixos-render-docs: default to markdown for options
docbook is now gone and we can flip the defaults. we won't keep the
command line args around (unlike the make-options-docs argument) because
nixos-render-docs should not be considered an exposed API.
2023-06-13 16:56:31 +02:00
pennae 5f35ae16ec nixos-render-docs: remove literalDocBook support
with literalDocBook itself gone we can also remove the support code in
nixos-render-docs.
2023-06-13 16:56:30 +02:00
figsoda f03d84d954 gridlock: init at unstable-2023-03-03
https://github.com/lf-/gridlock
2023-05-29 16:52:16 -04:00
maralorn 4414a2d948 nix-output-monitor: 2.0.0.5 -> 2.0.0.6
* Small improvements in error reporting.
* Significant performance improvements.
2023-05-14 23:11:42 +02:00
maralorn 72b021051f nix-output-monitor: comment and cleanup 2023-05-14 23:10:00 +02:00
John Ericson 57445260f0
Merge pull request #229113 from aschmolck/fix-nix-info-help
Fix nix-info --help to exit 0
2023-05-10 17:33:33 -04:00
Sandro Jäckel 00000001b4
treewide: switch builtins.fromJSON(builtins.readFile ./file.json) to lib.importJSON ./file.json #2 2023-05-06 16:20:13 +02:00
pennae 407f6196a2 nixos-render-docs: add examples support
the nixos manual contains enough examples to support them as a proper
toc entity with specialized rendering, and if in the future the nixpkgs
wants to use nixos-render-docs we will definitely have to support them.
this also allows us to restore some examples that were lost in previous
translation steps because there were too few to add renderer support
back then.
2023-05-03 19:58:21 +02:00
Alexander Schmolck eb811a6ee0 nix-info: fix nix-info --help to exit 0
Previously, --help and -h were treated like an invalid argument.
2023-04-30 13:04:09 +01:00
figsoda 87b94e2e4f nix-init: 0.2.2 -> 0.2.3
Diff: https://github.com/nix-community/nix-init/compare/v0.2.2...v0.2.3

Changelog: https://github.com/nix-community/nix-init/blob/v0.2.3/CHANGELOG.md
2023-04-29 19:27:22 -04:00
figsoda a6e90dec5f nix-melt: init at 0.1.2 2023-04-26 10:58:09 -04:00
figsoda c58c844b36 nix-init: 0.2.1 -> 0.2.2
Diff: https://github.com/nix-community/nix-init/compare/v0.2.1...v0.2.2

Changelog: https://github.com/nix-community/nix-init/blob/v0.2.2/CHANGELOG.md
2023-04-23 10:49:07 -04:00
figsoda d9d363bf3c nixpkgs-hammering: unstable-2022-11-15 -> unstable-2023-03-09
Diff: 1b038ef38f...243b81c687
2023-04-17 10:16:47 -04:00
Dennis Gosnell c00dc0cf7d
Merge remote-tracking branch 'origin/master' into haskell-updates 2023-03-27 08:42:30 +09:00
Yureka f8cbc3c281 tree-wide: convert rust with git deps to importCargoLock 2023-03-26 01:52:04 +01:00
Dennis Gosnell 9b7cbce8b2
Merge remote-tracking branch 'origin/master' into haskell-updates 2023-03-23 07:42:17 +09:00
Dennis Gosnell 3009eda91b
nix-output-monitor: use hermes-json-0.2.0.1 2023-03-22 21:46:11 +09:00
figsoda 80a7ce3920 nix-init: 0.2.0 -> 0.2.1
Diff: https://github.com/nix-community/nix-init/compare/v0.2.0...v0.2.1

Changelog: https://github.com/nix-community/nix-init/blob/v0.2.1/CHANGELOG.md
2023-03-21 21:04:45 -04:00
figsoda f129d39c77 nix-init: 0.1.1 -> 0.2.0
Diff: https://github.com/nix-community/nix-init/compare/v0.1.1...v0.2.0

Changelog: https://github.com/nix-community/nix-init/blob/v0.2.0/CHANGELOG.md
2023-03-20 09:41:23 -04:00
Sandro Jäckel d1a388ae8e
nixos-render-docs: use packageOverrides to construct python packages 2023-03-14 00:12:34 +01:00
Artturin 47ace7b0af pkgs/tools/nix: enable strictDeps
`fd "\.nix" pkgs/tools/nix | xargs rg "strictDeps" --files-without-match | xargs rg "buildRust|buildGo|buildPyt|buildNim" --files-without-match | xargs vim -p`

checked with Artturin/diffing
2023-03-07 18:13:44 +02:00
pennae 36f04733dd nixos-render-docs: add manual html converter
this converter is currently supposed to be able to reproduce the
docbook-generated html DOMs exactly, though not necessarily the
html *files*. it mirrors many docbook behaviours that seem rather odd,
such as top-level sections in chapters using the same heading depth as
understood by html as their parent chapters do. over time we can
hopefully remove all special casing needed to reproduce docbook
rendering, but for now at least it doesn't hurt *too* much.
2023-02-21 18:26:41 +01:00
pennae feaa97e5dc nixos-render-docs: render directly from file to file
this will be necessary for html since there we have to do chunking into
multiple files ourselves. writing one file from the caller of the
converter and all others from within the converter is unnecessarily
spread out, and returning a dict of file names and their contents is not
quite as meaningful for docbook (which has only one file to begin with).
2023-02-21 18:26:41 +01:00
pennae d520d55dee nixos-render-docs: add options html renderer
it's not hooked up to anything yet, but that will come soon. there's a
bit of docbook compat here that must be interoperable with the actual
docbook exporter, but luckily it's not all that much.
2023-02-21 18:26:41 +01:00
pennae 82e62614e9 nixos-render-docs: add html renderer
the basic html renderer. it doesn't have all the docbook compatibility
codes embedded into it, but there is a good amount. this renderer is
unaware of manual structure and does not traverse structural include
tokens (if it finds any it'll just fail), that task falls to derived
classes. once we have more uses for structural includes than just the
manual we may revisit this decision.
2023-02-21 18:26:41 +01:00
pennae 7a74ce51a1 nixos-render-docs: add toc generator
the docbook toolchain uses docbook-xsl to generate its TOC, our html
renderer will have to do this on its own. this generator uses a very
straight-forward algorithm of only inspecting headings, but anything
else could be inspected as well. (examples come to mind, but those do
not have titles and would thus make for bad toc entries)

we also use path information (that will be taken from include block args
in the html renderer) to produce navigation information. the algorithm
we use mirrors what docbook does, linking to the next/previous files in
depth-first toc order.

toc entries are linked to the tokens they refer to for easy use later.
2023-02-21 18:26:41 +01:00
pennae 23dc31a975 nixos-render-docs: allow for options in include blocks
while docbook relies on external chunk-toc info to do chunking of the
rendered manual we have nothing of the sort for html. there it seems
easiest to add annotations to blocks to create new chunks. such
annotations could be extended to docbook to create the chunk-toc instead
of passing it in externally, but with docbook on the way out that seems
like a waste of effort.
2023-02-21 18:26:41 +01:00
pennae 768794d6c1 nixos-render-docs: check book structure
text content in the toplevel file of a book will not render properly.
the first proper element will be a preface, part, or chapter anyway, and
those require includes to produce.

parts do not currently allow headings in the part file itself, but
that's mainly a renderer limitation. we can add support for headings in
part intros when we need them

in all other cases includes must be followed by either another include,
a heading, or end of file. text content could not be properly linked to
from a TOC without a preceding heading.
2023-02-21 18:26:40 +01:00
pennae 163b667352 nixos-render-docs: require headings to have ids
without this we cannot build a TOC to arbitrary depth without generating
ids for headings, but generated ids are fragile and liable to either
break or point to different things if the manual changes shape. we
already have the convention that all headings should have an id, this
formalizes it.
2023-02-21 18:26:40 +01:00
pennae ba20114460 nixos-render-docs: check heading continuity
while not technically necessary for correct rendering of *contents* we
do need to disallow heading levels being skipped to build a correct
TOC. treating headings that have skipped a number of levels to actually
be headings that many levels up only gets confusing, and inserting
artifical intermediate headings suffers from problems, such as which ids
to use and what to call them.
2023-02-21 18:26:40 +01:00
pennae 7b0824c003 nixos-render-docs: check heading presence during parsing
check that all required headings are present during parsing, not during
rendering. building a correct TOC will need this since every TOC entry
needs a heading to set its title, and every included substructure needs
a title.

also improve the error message on repeated title headings slightly,
giving the end line turns out to not be very useful.
2023-02-21 18:26:40 +01:00
pennae a7c25bb01f nixos-render-docs: add Freezable class
for most of our data classes we can use dataclasses.dataclass with
frozen=True or even plain named tuples. the TOC structure we'll need to
generate proper navigation links is most easily represented and used as
a cyclic structure though, and for that we can use neither. if we want
to make the TOC structures immutable (which seems like a good idea)
we'll need a hack of *some* kind, and this hack seems like the least intrusive.
2023-02-21 18:26:40 +01:00
pennae 2ab8e742a5 nixos-render-docs: move recursive manual parsing to base class
the html renderer will need all of these functions as well. some
extensions will be needed, but we'll add those as they become necessary.
2023-02-21 18:26:40 +01:00
pennae 5b8be28e66 nixos-render-docs: don't render options during manual parsing
we should really be rendering options at *rendering* time, not at parse
time. currently this is just an academic exercise, but the html renderer
will have to inspect the options.json data after the entire document has
been parsed, but before anything gets rendered.
2023-02-21 18:26:40 +01:00
pennae 068916ae8f nixos-render-docs: keep revision in renderer, not converter
ultimately it's the renderer that needs it, for the options rendering
that will be simplified in a bit.
2023-02-21 18:26:39 +01:00
pennae 6f253fc70b nixos-render-docs: drop options, env parameters
these weren't used for anything. options never was (and does not contain
any information for the renderer that we *want* to honor), and env is
not used because typed renderer state is much more useful for all our cases.
2023-02-21 18:26:39 +01:00
pennae 0236dcb59f nixos-render-docs: don't use markdown-it RendererProtocol
our renderers carry significantly more state than markdown-it wants to
easily cater for, and the html renderer will need even more state still.
relying on the markdown-it-provided rendering functions has already
proven to be a nuisance, and since parsing and rendering are split well
enough we can just replace the rendering part with our own stuff outright.

this also frees us from the tyranny of having to set instance variables
before calling super().__init__ just to make sure that the renderer
creation callback has access to everything it needs.
2023-02-21 18:26:39 +01:00
pennae 417dd2ad16 nixos-render-docs: add options asciidoc converter
same reasoning as for the earlier commonmark converter.
2023-02-21 18:19:00 +01:00
pennae 4d3aef762f nixos-render-docs: add options commonmark converter
the old method of pasting parts of options.json into a markdown document
and hoping for the best no longer works now that options.json contains
more than just docbook. given the infrastructure we have now we can
actually render options.md properly, so we may as well do that.
2023-02-21 18:19:00 +01:00
pennae 6c182075bb nixos-render-docs: forbid attrspans and examples in options
inline anchors are not allowed in option docs per the manual, and the
sole class we current have (.keycap) is never used anyway. disallow them
for now to avoid future surprises.

the same goes for examples, which aren't even documented in the manual yet.
2023-02-21 18:19:00 +01:00
pennae 82d066ffe3 nixos-render-docs: refactor option docs restrictions
move the restrictions we care about into a mixin class. a few more
restrictions will appear soon and a few new converters as well, the
renderers of which need not have these restrictions already baked in by
accident (like the manpage renderer does right now).
2023-02-21 18:19:00 +01:00
pennae 45619b3c4a nixos-render-docs: extend md_make_code
add the ability to set the info string for a newly created fenced code
block, and a flag to always emit a fenced block. the commonmark
converter will need this to faithfully recreate fenced and indented code
blocks.
2023-02-21 18:19:00 +01:00
pennae 895d9e69dd nixos-render-docs: extract md code block factory
the commonmark exporter can make good use once it appears.
2023-02-21 18:19:00 +01:00
pennae 00bffb84da nixos-render-docs: drop frozendict
with mypy type checking and Mapping types this is a lot less useful than
anticipated. let's drop it for simplicity and having fewer dependencies.

frozendict 2.3.5 also broke the mypy checks.
2023-02-21 18:19:00 +01:00
pennae 81cf173256 nixos-render-docs: use multiprocessing for options
options processing is pretty slow right now, mostly because the
markdown-it-py parser is pure python (and with performance
pessimizations at that). options parsing *is* embarassingly parallel
though, so we can just fork out all the work to worker processes and
collect the results.

multiprocessing probably has a greater benefit on linux than on darwin
since the worker spawning method darwin uses is less efficient than
fork() on linux. this hasn't been tested on darwin, only on linux, but
if anything darwin will be faster with its preferred method.
2023-02-18 13:17:57 +01:00
Robert Hensing b72592ee04
Merge pull request #215973 from pennae/nrd-manual-structure
nixos/manual: specify manual structure in markdown
2023-02-17 18:01:23 +01:00
Felix Buehler bc3d5934d7 treewide: use lib.optionals 2023-02-14 19:11:59 +01:00
pennae 1229e735ac nixos-render-docs: add structural includes, use for manual
this adds support for structural includes to nixos-render-docs.
structural includes provide a way to denote the (sub)structure of the
nixos manual in the markdown source files, very similar to how we used
literal docbook blocks before, and are processed by nixos-render-docs
without involvement of xml tooling. this will ultimately allow us to
emit the nixos manual in other formats as well, e.g. html, without going
through docbook at all.

alternatives to this source layout were also considered:

a parallel structure using e.g. toml files that describe the document
tree and links to each part is possible, but much more complicated to
implement than the solution chosen here and makes it harder to follow
which files have what substructure. it also makes it much harder to
include a substructure in the middle of a file.

much the same goes for command-line arguments to the converter, only
that command-lined arguments are even harder to specify correctly and
cannot be reasonably pulled together from many places without involving
another layer of tooling. cli arguments would also mean that the manual
structure would be fixed in default.nix, which is also not ideal.
2023-02-12 13:02:42 +01:00