summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2022-05-06refactor: replace SubplotError::YamlError with more specific oneLars Wirzenius3-12/+6
SubplotError::YamlError is quite generic. We only parse YAML as part of document metadata, so replace the error with a more specific one. Sponsored-by: author
2022-05-06refactor: replace generic Pandoc error with specificLars Wirzenius2-11/+4
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 Wirzenius5-24/+57
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 Wirzenius9-51/+78
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-04-26refactor: use "diagram" instead of "graph"Lars Wirzenius4-22/+22
Change everywhere to use the word "diagram" instead of "graph. Diagram seems like the better word. It's mostly used in comments and documentation, but there was one filename and one trait name that needed changing. I used "rg -iw graph" and "find -iname '*graph*'" to find everywhere that needed changing. Sponsored-by: author
2022-04-15feat: improve logging via env_loggerLars Wirzenius2-12/+53
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 Wirzenius3-13/+18
Sponsored-by: author
2022-04-10chore: drop unnecessary, if harmless, debugging print from testLars Wirzenius1-1/+0
Sponsored-by: author
2022-04-10feat: report markup problems during typesetting as a warningLars Wirzenius3-12/+24
Sponsored-by: author
2022-04-10feat: make typesetting issues into warningsLars Wirzenius4-11/+30
Sponsored-by: author
2022-04-10feat! treat warnings as errors by defaultLars Wirzenius4-35/+84
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 Wirzenius3-12/+49
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 Wirzenius8-208/+73
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
2022-03-12(chore): Update various crates a bit moreDaniel Silverstone1-1/+3
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-02-02chore: rewrite use of chorno crate to use just time crateLars Wirzenius1-3/+6
Also, sort the dependency list in Cargo.toml so it's tidy. Sponsored-by: author
2022-01-26feat: automatically use "and" on outputLars Wirzenius1-8/+18
This changes typesetting of scenarios so that when two adjacent scenario steps have the same keyword, "and" is used on the second one. This means that when input has when I do foo when I do bar the output will have when I do foo and I do bar I didn't bother to make this configurable. I don't feel that level of configuration is good. The "keyword aliases" scenario is repurposed to verify this. Sponsored-by: author
2022-01-25chore: use Display, instead of .to_stringLars Wirzenius1-1/+1
Sponsored-by: author
2021-12-27codegen: Refuse to generate code if the specified template is not presentDaniel Silverstone2-0/+12
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-12-11chore: tidy up minor issues found by clippyLars Wirzenius2-8/+2
Sponsored-by: author
2021-11-27feat: warn about unused embedded filesLars Wirzenius2-2/+45
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-19metadata: Switch to using pullmark parsingDaniel Silverstone1-2/+5
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19ast: Build images into the partial ASTDaniel Silverstone1-1/+10
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19ast: Pass bibliographies on properlyDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19metadata: Write out templates too, to make it easier to parseDaniel Silverstone1-0/+2
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-11-19subplot: Rework for impls not template/functionsDaniel Silverstone5-70/+80
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 Silverstone7-69/+157
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>
2021-10-17fix: regex for extracting YAML from MarkdownLars Wirzenius1-9/+15
The old regex had a wrong, and weird, pattern for lines of YAML. The new one is simpler and seems more correct: it matches lines not staring with a dot. Sponsored-by: author
2021-10-13feat: add crate subplot-build for using Subplot from build.rsLars Wirzenius5-73/+101
Make it easy to generate test code from a subplot in another project's `build.rs` script. Move the code to load documents and generate test code from src/bin/subplot.rs and src/bin/cli/mod.rs to src/doc.rs so it can be used without using the subplot executable. Make the add_search_path function public so it can be used outside its module. The subplot executable arranged for the directory where the markdown input file resides to be added to the search path via another way. Sponsored-by: pep.foundation
2021-10-12fix(portability): avoid using str::split_onceLars Wirzenius1-1/+3
Sequoia wants Rust 1.48.0 and split_once is not in that version. We can easily accommodate Sequoia's needs here with a simple change. Sponsored-by: author
2021-10-08codegen: Refuse to codegen if there are zero scenariosDaniel Silverstone2-1/+11
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-18Merge branch 'fix-documentclass' into 'main'Daniel Silverstone1-0/+4
feat: allow the `documentclass` field in document metadata Closes #237 See merge request subplot/subplot!216
2021-09-18feat: allow the `documentclass` field in document metadataLars Wirzenius1-0/+4
With the new pulldown-cmark parser for codegen, we are explicit about what fields we allow in the YAML document metadata block. We currently don't allow the `documentclass` field. Allow it. It's a useful way for controlling typesetting vie LaTeX to PDF. Sponsored-by: author
2021-09-18pandoc: Add support for --citeprocDaniel Silverstone2-2/+25
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-18trace: Add scenario count traceDaniel Silverstone1-0/+6
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-18ast: codeblocks with single words are classes not IDsDaniel Silverstone1-3/+4
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-18ast: Codeblocks should not have extra trailing newlinesDaniel Silverstone1-0/+6
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-16feat! parse Markdown input with pull-cmark instead of PandocLars Wirzenius7-8/+537
This is a first step towards being able to use Subplot codegen from a project's build.rs, and with only pure-Rust build dependencies. Replace Pandoc for parsing Markdown input with pulldown-cmark. This is mostly a drop-in replacement, but not entirely. The YAML parsing is more strict now. Note that this is a breaking change. Some subplots that used to work, and still work with docgen, no longer work with the new parser. Major differences are: * Only specific fields are supported. All the Markdown files in the Subplot source tree work. If anything else is needed, and it likely is, the new parser needs to be extended. * The bindings, functions, classes, and bibliography fields MUST be lists of strings. A single string value will no longer work. Sponsored-by: pep.foundation
2021-09-14debug: add tracing calls to help debugLars Wirzenius3-4/+37
I needed these to figure out a problem that wasn't in Subplot itself. I'd like to keep them for the future. Sponsored-by: author
2021-09-13Merge branch 'multi-lang-docs' into 'main'Lars Wirzenius9-253/+273
Implement polyglot bindings See merge request subplot/subplot!210
2021-09-09fix: handle most inline markup in metadata titlesLars Wirzenius1-0/+1
Actually, we only didn't handle `foo` code markup. Sponsored-by: author
2021-09-07chore: Rename generated file for resources to ease developmentDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07core: Adjust behaviour for bindings and function file findingDaniel Silverstone2-32/+34
From now on, we search $ common/$ then template/$ and as such we will find common (polyglot) bindings automatically Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07subplot: Properly support polyglot bindingsDaniel Silverstone6-37/+79
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07bindings: Parse polyglot bindingsDaniel Silverstone1-12/+50
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07bindings: Remove redundant function/cleanupDaniel Silverstone1-27/+2
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07bindings: Initial move toward multi-lingual bindingsDaniel Silverstone2-138/+48
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07bindings: Refactor function+cleanup into a structDaniel Silverstone1-6/+59
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-07chore: Unwind global template nameDaniel Silverstone6-27/+27
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-09-06fix: build resources into subplot binary even in Debian packageLars Wirzenius1-11/+1
Once upon a time, in a galaxy far, far away, we decided to not build the share/* resource files into the subplot binary, when building it for a Debian package. Much later, we were much surprised when this was not the case and tests fail when run during the Debian package build. Because it's surprising to not build in the resources for a Debian package, we hereby undo that decision. Sponsored-by: author
2021-09-05resources: Hidden subcommand to list internal resourcesDaniel Silverstone2-0/+24
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>