summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
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 Wirzenius2-25/+10
Sponsored-by: author
2022-09-03refactor: expose functionality to extract embedded YAML from mdLars Wirzenius2-54/+36
Sponsored-by: author
2022-09-03refactor: delay use of pandoc_ast::Map to as late as possibleLars Wirzenius1-8/+6
Use YamlMetadata instead. I find this to be clearer and that it reduces the coupling with pandoc_ast a little. This should help us when we implement document metadata in a separate YAML file instead of embedding it in the Markdown. Sponsored-by: author
2022-09-03refactor: make long function a little more readable with empty linesLars Wirzenius1-0/+10
Sponsored-by: author
2022-09-03refactor: use the more idiomatic Into to convert &str to StringLars Wirzenius1-13/+9
The helper function was unnecessary baggage, written by an inexperienced Rust programmer (i.e., me, three years ago). It's time to let go. Sponsored-by: author
2022-09-03refactor: rename ast::Metadata to ast::YamlMetadata for clarityLars Wirzenius1-6/+6
This reduces the confusion with metadata::Metadata and Pandoc's metadata. Sponsored-by: author
2022-09-03refactor: rename DataFile{,s} to EmbeddedFile{,s} to be systematicLars Wirzenius7-29/+29
Sponsored-by: author
2022-09-03refactor: add a type for SVG imagesLars Wirzenius3-12/+38
This allows us to not use a generic byte vector, and slightly lessens the chance of mistakes. Also, it strongly encodes what we need to know about and do with SVG images. Sponsored-by: author
2022-08-14feat! drop support to act as a Pandoc filterLars Wirzenius2-74/+2
When we change Subplot to take a YAML file instead of a Markdown file as input, it doesn't make sense to act as a Pandoc filter anymore: Pandoc doesn't understand our YAML file. In any case, I seem to have been the only user ever of that feature, so it won't really bother anyone else. Even so, we should treat this as a breaking change. "subplot docgen" still works as before. Sponsored-by: author
2022-08-13Merge branch 'liw/refactor-errors' into 'main'Daniel Silverstone2-15/+16
feat: make errors have a source error See merge request subplot/subplot!284
2022-08-13feat: make errors have a source errorLars Wirzenius2-15/+16
When errors have a source, i.e., an underlying error, it results in better error messages to the user. Also, refactor the way the source chain is printed, to code that is clearer to me. I will need this to for loading document metadata from an external YAML file. Sponsored-by: author
2022-07-30chore: handle write! errorsLars Wirzenius2-1/+5
Sponsored-by: author
2022-07-02(subplot): Use .unwrap_or()Daniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-07-02(bindings): use Write macro for cleaner string updateDaniel Silverstone1-2/+2
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-07-02(doc): Remove unnecessary lifetime markerDaniel Silverstone1-1/+1
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-05-14(cli): Change from structopt to clap3-deriveDaniel Silverstone3-45/+44
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2022-05-06Merge branch 'liw/tidy-up-error' into 'main'Daniel Silverstone10-117/+154
tidy up error handling a bit See merge request subplot/subplot!275
2022-05-06refactor: replace SubplotError::JsonError with a more specific oneLars Wirzenius2-12/+5
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 SubplotError::RegexError with a simpler oneLars Wirzenius2-7/+4
SubplotError::RegexError was a struct variant in the enum. Replace it with a more usual variant with the regex::Error as a source field, for better error messaging. Sponsored-by: author
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-05-04(subplot): Add support for example blocksDaniel Silverstone4-3/+10
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-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