summaryrefslogtreecommitdiff
path: root/src/doc.rs
AgeCommit message (Collapse)AuthorFilesLines
5 daysrefactor: move all typesetting (HTML generation) to src/typeset.rsLars Wirzenius1-252/+7
This paves the way for a future change where src/html.rs is replaced with the html-page crate. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-12-27bindings: Add warnings for missing capture names or missing capture typesDaniel Silverstone1-0/+5
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2023-12-25feat: typeset scenarios by typesetting stepsLars Wirzenius1-4/+19
Typeset each step in a scenario, including captures in the steps. Previously the scenario was just one <pre> element, now things can be styled with CSS. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-12-25refactor: move CSS file out of doc.rsLars Wirzenius1-8/+7
Make it easier to edit the CSS file, and also add some styles for upcoming scenario typesetting. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-10-31feat: add some HTML class attributesLars Wirzenius1-1/+11
This is a start. We'll need to add more as we add more support for styling the output. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-10-31div for page body classLars Wirzenius1-0/+1
Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-10-30feat: allow adding CSS URLs to HTML outputLars Wirzenius1-0/+8
This is in the meta data field "css_urls". Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-10-30feat: allow .subplot to list CSS files to embed in HTML outputLars Wirzenius1-0/+3
This is in the meta data field "css_embed". Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-10-21feat: insert a Table of Contents into generated HTMLLars Wirzenius1-2/+181
Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
2023-07-02feat! drop support for bibliographies in document metadataLars Wirzenius1-4/+0
We don't use the bibliographies for anything so there's not point in allowing users to specify it. If and when we add support for bibliographies again, we may well want to do it in a different way. Alas, we also have to disable reference.md because the release it refers to uses bibliographies. We'll have to re-enable it again after the next release. Sponsored-by: author
2023-06-21refactor: rename Document::files to ::embedded_filesLars Wirzenius1-4/+8
This makes it more clear what kind of files we're talking about. The old name could've meant, say, the markdown files. Sponsored-by: author
2023-06-21refactor: inline Document::from_ast to its only call siteLars Wirzenius1-20/+4
The extra method doesn't provide anything useful to it's better inline. Sponsored-by: author
2023-06-15refactor: change Document::to_html to return a ResultLars Wirzenius1-2/+2
HTML generation uses write!, which can fail, so to_html must return a Result. Sponsored-by: author
2023-06-10feat: Warn when named codeblocks lack classesDaniel Silverstone1-1/+37
To both improve debugability when writing scenarios, and also to protect against future incompatibilities which might occur if we add more classes which are appropriate for named code blocks, we require that named blocks have one of `file` or `example` as classes or else we warn. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2023-05-19tests: verify that Subplot reports specific errors with locationLars Wirzenius1-4/+4
Sponsored-by: author
2023-05-14feat: check for duplicate scenario titlesLars Wirzenius1-0/+13
Sponsored-by: author
2023-05-10feat! allow multiple markdown files for a subplotLars Wirzenius1-17/+51
Sponsored-by: author
2023-05-10refactor: move document metadata out of Markdown structLars Wirzenius1-5/+44
It's _document_ metadata, not metadata for a specific markdown file. It belongs in Document, not Markdown. Make it so. Sponsored-by: author
2023-04-08feat: drop use of Pandoc from doc.rsLars Wirzenius1-17/+18
Sponsored-by: author
2023-04-08refactor(src/doc.rs): rename constant to not refer to PandocLars Wirzenius1-5/+5
Sponsored-by: author
2023-02-25(doc, md, bin): Update APIs so warnings are externally accumulatedDaniel Silverstone1-22/+20
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2023-02-25(doc): Remove use of mut in Document method receivers where possibleDaniel Silverstone1-9/+6
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2023-02-12refactor: drop Document::markdowns fieldLars Wirzenius1-18/+3
The same information is in the metadata, so use that instead. Sponsored-by: author
2023-02-01refactor: turn loading Markdown from a file into a constructorLars Wirzenius1-2/+1
Previously, we used the TryFrom<&Path> trait, but it's not clear that converting a pathname into a Markdown value means reading it. An associated function that reads a file is clearer. Sponsored-by: author
2023-02-01refactor: only mutating methods on Markdown require mutable selfLars Wirzenius1-1/+1
Use RefCell's interior mutability to work around the fact that pandoc_ast's MutVisitor requires a mutable reference to self. Sponsored-by: author
2023-01-28refactor: move YamlMetadata to src/metadata.rsLars Wirzenius1-5/+3
YamlMetadata was in src/ast.rs, because originally it was only used to parse metadata out of Markdown. Markdown parsing is now in its own module, leaving ast.rs to only contain YamlMetadata. In this situation, it seems tidy to have both kinds of metadata in the same module, and to drop the now-empty ast.rs module. Sponsored-by: author
2023-01-22refactor: use new Markdown type instead of pandoc_ast visitorsLars Wirzenius1-283/+38
Sponsored-by: author
2022-09-28fix: include the subplot in the sources of the documentLars Wirzenius1-4/+17
This means that if only the subplot is modified, docgen will rebuild the output. Sponsored-by: author
2022-09-06feat! read document metadata from a YAML fileLars Wirzenius1-13/+38
This is a huge change all in one commit, sorry. However, as it changes a fundamental part of the command line interface (namely, what constitutes as the input file), there doesn't seem a way to break this into a tidy series of small commits. Most of the diff is in subplot.md, where every scenario that invokes Subplot needs multiple changes, thus touching much of the file. The overall change is that where we previously had document metadata in embedded YAML in the Markdown file, we now have it in a separate YAML file. The Markdown file is named in the YAML file. We still parse the Markdown with Pandoc for everything, except codegen. Switching from Pandoc to pulldown_cmark for parsing will be another big change that I didn't want to include in this huge change set. Sponsored-by: author
2022-09-03refactor: drop unnecessary single-line function used from one callerLars Wirzenius1-19/+10
Sponsored-by: author
2022-09-03refactor: AST only parses Markdown, YAML is extracted outside itLars Wirzenius1-2/+2
Sponsored-by: author
2022-09-03refactor: rename DataFile{,s} to EmbeddedFile{,s} to be systematicLars Wirzenius1-6/+6
Sponsored-by: author
2022-07-02(doc): Remove unnecessary lifetime markerDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-05-06Merge branch 'liw/tidy-up-error' into 'main'Daniel Silverstone1-25/+40
tidy up error handling a bit See merge request subplot/subplot!275
2022-05-06refactor: replace SubplotError::JsonError with a more specific oneLars Wirzenius1-2/+2
SubplotError::JsonError is a generic error, but we actually only parse JSON when parsing the AST from Pandoc. Replace it with a ::AstJson error to be more specific, and hopefully more helpful to the user. Sponsored-by: author
2022-05-06refactor: replace generic Pandoc error with specificLars Wirzenius1-1/+1
Replace SubplotError::PandocError with ::Pandoc, which is only for executing the Pandoc program. In reality, so was the old variant, but the new one is more specific, and also embeds the error from executing Pandoc as a source error. The error message is still crap, but that will be fixed later by not using Pandoc for parsing Markdown. Sponsored-by: author
2022-05-06refactor! split SubplotError::IoError into more specific errorsLars Wirzenius1-1/+2
Replace SubplotError::IoError with ::Spawn, ::WriteToChild, ::WaitForChild, ::ReadFile, ::CreateFile, ::Writefile. IoError was a catchall error and as such, so generic that it didn't help the user to figure out what actually is wrong. For example, there was no indication what operation was attempted or on what file. The new error variants are specific. Sponsored-by: author
2022-05-05refactor: drop the subplot::Result type aliasLars Wirzenius1-21/+35
Replace subplot::Result<T> with Result<T, SubplotError>. I find this now to be clearer, as I don't need to remind myself which Result is being used where. This should not be a breaking change. Sponsored-by: author
2022-05-04(subplot): Add support for example blocksDaniel Silverstone1-1/+3
In support of #256, this adds `example` as a permitted class and ensures that we typeset it as though it were a file. This includes linting it as though it were a file too. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-04-15feat: improve logging via env_loggerLars Wirzenius1-2/+7
Configure env_logger from environment, including style (colors). Simplify how log messages are formatted: drop the timestamp and crate name, as they're just noise for the case of Subplot. Adjust log messages so that what a user may want to normally know is info or above, and at level debug if they want to see in more detail what's happening. Handle the error from failing to execute pandoc specially, for a better error message. The default error message from the pandoc crate was hard for a user to understand. The new message clearly says what the exit code is, and logs the stderr, but not stdout, as Pandoc correctly writes errors only to stderr. Sponsored-by: author
2022-04-10use Option<&str> instead of &Option<String>Lars Wirzenius1-1/+1
Sponsored-by: author
2022-04-10chore: drop unnecessary, if harmless, debugging print from testLars Wirzenius1-1/+0
Sponsored-by: author
2022-04-10feat: make typesetting issues into warningsLars Wirzenius1-0/+1
Sponsored-by: author
2022-04-10feat! treat warnings as errors by defaultLars Wirzenius1-4/+17
Add a --merciful option to subcommands for which this matters. Adjust tests to invoke subplot with that option as necessary. Sponsored-by: author
2022-04-10refactor: collect warnings for a document in its DocumentLars Wirzenius1-12/+11
Change places where warnings used to be written out so the warnings are pushed into the list in Document instead. Sponsored-by: author
2022-03-24feat! change logging to use log/env_logger instead of tracingLars Wirzenius1-58/+25
We don't use async in Subplot, and the mental overhead of learning tracing and the code overhead to add support for logging custom values (implementing the Value trait for Subplot internal types) does not seem worthwhile. Sponsored-by: author
2021-12-27codegen: Refuse to generate code if the specified template is not presentDaniel Silverstone1-0/+3
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-27feat: warn about unused embedded filesLars Wirzenius1-1/+42
This is merely a warning, for now, to stderr. subplot.md has two embedded files used as examples, and I'm too tired to add a way to indicate that it's OK for a specific file to not be used. That should probably be added later, though. Sponsored-by: author
2021-11-19subplot: Rework for impls not template/functionsDaniel Silverstone1-11/+23
As the next step in polyglot documents, this reworks the internals to expect the metadata of documents to contain an impls mapping from template name to function filenames for that template. Sadly this does mean that if there're no function files, the document author will have to still specify an empty list, but that seems acceptable. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19various: Rework document to support multiple implementationsDaniel Silverstone1-15/+37
In order to eventually shift the document metadata to support more than one template defined for the document this reworks all the internal APIs to expect templates, and also the external CLI to be able to provide it. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>