mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Shorten some names ↔
This commit is contained in:
parent
a41d7ab47d
commit
ef8aa763fa
@ -45,25 +45,24 @@ fn main() {
|
|||||||
let state = State::default();
|
let state = State::default();
|
||||||
let Pass {
|
let Pass {
|
||||||
output: layouts,
|
output: layouts,
|
||||||
feedback: Feedback { mut diagnostics, .. },
|
feedback: Feedback { mut diags, .. },
|
||||||
} = block_on(typeset(&src, state, Rc::clone(&loader)));
|
} = block_on(typeset(&src, state, Rc::clone(&loader)));
|
||||||
|
|
||||||
if !diagnostics.is_empty() {
|
if !diags.is_empty() {
|
||||||
diagnostics.sort();
|
diags.sort();
|
||||||
|
|
||||||
let map = LineMap::new(&src);
|
let map = LineMap::new(&src);
|
||||||
for diagnostic in diagnostics {
|
for diag in diags {
|
||||||
let span = diagnostic.span;
|
let span = diag.span;
|
||||||
let start = map.location(span.start);
|
let start = map.location(span.start);
|
||||||
let end = map.location(span.end);
|
let end = map.location(span.end);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
" {}: {}:{}-{}: {}",
|
" {}: {}:{}-{}: {}",
|
||||||
diagnostic.v.level,
|
diag.v.level,
|
||||||
src_path.display(),
|
src_path.display(),
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
diagnostic.v.message,
|
diag.v.message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
//! Diagnostics for source code.
|
//! Diagnostics for source code.
|
||||||
//!
|
//!
|
||||||
//! There are no fatal errors. The document will always compile and yield a
|
//! There are no fatal errors. The document will always compile and yield a
|
||||||
//! layout on a best effort process, generating diagnostics for incorrect
|
//! layout on a best effort process, but diagnostics are nevertheless generated
|
||||||
//! things.
|
//! for incorrect things.
|
||||||
|
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
/// A diagnostic that arose in parsing or layouting.
|
/// A diagnostic that arose in parsing or layouting.
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
pub struct Diagnostic {
|
pub struct Diag {
|
||||||
/// How severe / important the diagnostic is.
|
/// How severe / important the diagnostic is.
|
||||||
pub level: Level,
|
pub level: Level,
|
||||||
/// A message describing the diagnostic.
|
/// A message describing the diagnostic.
|
||||||
@ -25,10 +25,10 @@ pub enum Level {
|
|||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Diagnostic {
|
impl Diag {
|
||||||
/// Create a new diagnostic from message and level.
|
/// Create a new diagnostic from message and level.
|
||||||
pub fn new(message: impl Into<String>, level: Level) -> Self {
|
pub fn new(level: Level, message: impl Into<String>) -> Self {
|
||||||
Self { message: message.into(), level }
|
Self { level, message: message.into() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ impl Display for Level {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! error {
|
macro_rules! error {
|
||||||
($($tts:tt)*) => {
|
($($tts:tt)*) => {
|
||||||
$crate::__impl_diagnostic!($crate::diagnostic::Level::Error; $($tts)*)
|
$crate::__impl_diagnostic!($crate::diag::Level::Error; $($tts)*)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ macro_rules! error {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! warning {
|
macro_rules! warning {
|
||||||
($($tts:tt)*) => {
|
($($tts:tt)*) => {
|
||||||
$crate::__impl_diagnostic!($crate::diagnostic::Level::Warning; $($tts)*)
|
$crate::__impl_diagnostic!($crate::diag::Level::Warning; $($tts)*)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +86,11 @@ macro_rules! warning {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! __impl_diagnostic {
|
macro_rules! __impl_diagnostic {
|
||||||
($level:expr; @$feedback:expr, $($tts:tt)*) => {
|
($level:expr; @$feedback:expr, $($tts:tt)*) => {
|
||||||
$feedback.diagnostics.push($crate::__impl_diagnostic!($level; $($tts)*));
|
$feedback.diags.push($crate::__impl_diagnostic!($level; $($tts)*));
|
||||||
};
|
};
|
||||||
|
|
||||||
($level:expr; $fmt:literal $($tts:tt)*) => {
|
($level:expr; $fmt:literal $($tts:tt)*) => {
|
||||||
$crate::diagnostic::Diagnostic::new(format!($fmt $($tts)*), $level)
|
$crate::diag::Diag::new($level, format!($fmt $($tts)*))
|
||||||
};
|
};
|
||||||
|
|
||||||
($level:expr; $span:expr, $fmt:literal $($tts:tt)*) => {
|
($level:expr; $span:expr, $fmt:literal $($tts:tt)*) => {
|
@ -90,13 +90,13 @@ impl Eval for ExprCall {
|
|||||||
let span = self.name.span;
|
let span = self.name.span;
|
||||||
let args = self.args.eval(ctx).await;
|
let args = self.args.eval(ctx).await;
|
||||||
|
|
||||||
if let Some(func) = ctx.state.scope.func(name) {
|
if let Some(func) = ctx.state.scope.get(name) {
|
||||||
ctx.f.decorations.push(Decoration::Resolved.span_with(span));
|
ctx.f.decos.push(Deco::Resolved.span_with(span));
|
||||||
(func.clone())(args, ctx).await
|
(func.clone())(args, ctx).await
|
||||||
} else {
|
} else {
|
||||||
if !name.is_empty() {
|
if !name.is_empty() {
|
||||||
error!(@ctx.f, span, "unknown function");
|
error!(@ctx.f, span, "unknown function");
|
||||||
ctx.f.decorations.push(Decoration::Unresolved.span_with(span));
|
ctx.f.decos.push(Deco::Unresolved.span_with(span));
|
||||||
}
|
}
|
||||||
Value::Dict(args)
|
Value::Dict(args)
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@ impl Scope {
|
|||||||
Self { functions: HashMap::new() }
|
Self { functions: HashMap::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Associate the given name with the function.
|
/// Return the function with the given name if there is one.
|
||||||
pub fn insert(&mut self, name: impl Into<String>, function: ValueFunc) {
|
pub fn get(&self, name: &str) -> Option<&ValueFunc> {
|
||||||
self.functions.insert(name.into(), function);
|
self.functions.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the function with the given name if there is one.
|
/// Associate the given name with the function.
|
||||||
pub fn func(&self, name: &str) -> Option<&ValueFunc> {
|
pub fn set(&mut self, name: impl Into<String>, function: ValueFunc) {
|
||||||
self.functions.get(name)
|
self.functions.insert(name.into(), function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ impl TextState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The absolute paragraph spacing.
|
/// The absolute paragraph spacing.
|
||||||
pub fn paragraph_spacing(&self) -> f64 {
|
pub fn par_spacing(&self) -> f64 {
|
||||||
self.par_spacing.eval(self.font_size())
|
self.par_spacing.eval(self.font_size())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,10 +530,7 @@ mod tests {
|
|||||||
dict.expect::<String>("", Span::ZERO, &mut f),
|
dict.expect::<String>("", Span::ZERO, &mut f),
|
||||||
Some("hi".to_string())
|
Some("hi".to_string())
|
||||||
);
|
);
|
||||||
assert_eq!(f.diagnostics, [error!(
|
assert_eq!(f.diags, [error!(Span::ZERO, "expected string, found bool")]);
|
||||||
Span::ZERO,
|
|
||||||
"expected string, found bool"
|
|
||||||
)]);
|
|
||||||
assert_eq!(dict.len(), 1);
|
assert_eq!(dict.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,10 +542,7 @@ mod tests {
|
|||||||
dict.insert("hi", entry(Value::Bool(true)));
|
dict.insert("hi", entry(Value::Bool(true)));
|
||||||
assert_eq!(dict.take::<bool>(), Some(false));
|
assert_eq!(dict.take::<bool>(), Some(false));
|
||||||
assert_eq!(dict.take_key::<f64>("hi", &mut f), None);
|
assert_eq!(dict.take_key::<f64>("hi", &mut f), None);
|
||||||
assert_eq!(f.diagnostics, [error!(
|
assert_eq!(f.diags, [error!(Span::ZERO, "expected float, found bool")]);
|
||||||
Span::ZERO,
|
|
||||||
"expected float, found bool"
|
|
||||||
)]);
|
|
||||||
assert!(dict.is_empty());
|
assert!(dict.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use super::*;
|
|||||||
use crate::eval::Eval;
|
use crate::eval::Eval;
|
||||||
use crate::shaping;
|
use crate::shaping;
|
||||||
use crate::syntax::{
|
use crate::syntax::{
|
||||||
Decoration, Expr, NodeHeading, NodeRaw, Span, SpanWith, Spanned, SynNode, SynTree,
|
Deco, Expr, NodeHeading, NodeRaw, Span, SpanWith, Spanned, SynNode, SynTree,
|
||||||
};
|
};
|
||||||
use crate::DynFuture;
|
use crate::DynFuture;
|
||||||
|
|
||||||
@ -52,18 +52,18 @@ impl<'a> TreeLayouter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn layout_node(&mut self, node: &Spanned<SynNode>) {
|
async fn layout_node(&mut self, node: &Spanned<SynNode>) {
|
||||||
let decorate = |this: &mut Self, deco: Decoration| {
|
let decorate = |this: &mut Self, deco: Deco| {
|
||||||
this.ctx.f.decorations.push(deco.span_with(node.span));
|
this.ctx.f.decos.push(deco.span_with(node.span));
|
||||||
};
|
};
|
||||||
|
|
||||||
match &node.v {
|
match &node.v {
|
||||||
SynNode::Space => self.layout_space(),
|
SynNode::Space => self.layout_space(),
|
||||||
SynNode::Text(text) => {
|
SynNode::Text(text) => {
|
||||||
if self.ctx.state.text.emph {
|
if self.ctx.state.text.emph {
|
||||||
decorate(self, Decoration::Emph);
|
decorate(self, Deco::Emph);
|
||||||
}
|
}
|
||||||
if self.ctx.state.text.strong {
|
if self.ctx.state.text.strong {
|
||||||
decorate(self, Decoration::Strong);
|
decorate(self, Deco::Strong);
|
||||||
}
|
}
|
||||||
self.layout_text(text).await;
|
self.layout_text(text).await;
|
||||||
}
|
}
|
||||||
@ -72,11 +72,11 @@ impl<'a> TreeLayouter<'a> {
|
|||||||
SynNode::Parbreak => self.layout_parbreak(),
|
SynNode::Parbreak => self.layout_parbreak(),
|
||||||
SynNode::Emph => {
|
SynNode::Emph => {
|
||||||
self.ctx.state.text.emph ^= true;
|
self.ctx.state.text.emph ^= true;
|
||||||
decorate(self, Decoration::Emph);
|
decorate(self, Deco::Emph);
|
||||||
}
|
}
|
||||||
SynNode::Strong => {
|
SynNode::Strong => {
|
||||||
self.ctx.state.text.strong ^= true;
|
self.ctx.state.text.strong ^= true;
|
||||||
decorate(self, Decoration::Strong);
|
decorate(self, Deco::Strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
SynNode::Heading(heading) => self.layout_heading(heading).await,
|
SynNode::Heading(heading) => self.layout_heading(heading).await,
|
||||||
@ -95,7 +95,7 @@ impl<'a> TreeLayouter<'a> {
|
|||||||
|
|
||||||
fn layout_parbreak(&mut self) {
|
fn layout_parbreak(&mut self) {
|
||||||
self.layouter.add_secondary_spacing(
|
self.layouter.add_secondary_spacing(
|
||||||
self.ctx.state.text.paragraph_spacing(),
|
self.ctx.state.text.par_spacing(),
|
||||||
SpacingKind::PARAGRAPH,
|
SpacingKind::PARAGRAPH,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ impl<'a> TreeLayouter<'a> {
|
|||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
@self.ctx.f, span,
|
@self.ctx.f, span,
|
||||||
"page break cannot only be issued from root context",
|
"page break can only be issued from root context",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ impl<'a> TreeLayouter<'a> {
|
|||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
@self.ctx.f, span,
|
@self.ctx.f, span,
|
||||||
"page style cannot only be changed from root context",
|
"page style can only be changed from root context",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/lib.rs
20
src/lib.rs
@ -22,7 +22,7 @@
|
|||||||
//! [`MultiLayout`]: layout/type.MultiLayout.html
|
//! [`MultiLayout`]: layout/type.MultiLayout.html
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod diagnostic;
|
pub mod diag;
|
||||||
|
|
||||||
pub mod color;
|
pub mod color;
|
||||||
pub mod eval;
|
pub mod eval;
|
||||||
@ -42,11 +42,11 @@ use std::fmt::Debug;
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
use crate::diagnostic::Diagnostic;
|
use crate::diag::Diag;
|
||||||
use crate::eval::State;
|
use crate::eval::State;
|
||||||
use crate::font::SharedFontLoader;
|
use crate::font::SharedFontLoader;
|
||||||
use crate::layout::BoxLayout;
|
use crate::layout::BoxLayout;
|
||||||
use crate::syntax::{Decoration, Offset, Pos, SpanVec};
|
use crate::syntax::{Deco, Offset, Pos, SpanVec};
|
||||||
|
|
||||||
/// Process source code directly into a collection of layouts.
|
/// Process source code directly into a collection of layouts.
|
||||||
pub async fn typeset(
|
pub async fn typeset(
|
||||||
@ -97,15 +97,15 @@ impl<T> Pass<T> {
|
|||||||
#[derive(Debug, Default, Clone, Eq, PartialEq)]
|
#[derive(Debug, Default, Clone, Eq, PartialEq)]
|
||||||
pub struct Feedback {
|
pub struct Feedback {
|
||||||
/// Diagnostics about the source code.
|
/// Diagnostics about the source code.
|
||||||
pub diagnostics: SpanVec<Diagnostic>,
|
pub diags: SpanVec<Diag>,
|
||||||
/// Decorations of the source code for semantic syntax highlighting.
|
/// Decorations of the source code for semantic syntax highlighting.
|
||||||
pub decorations: SpanVec<Decoration>,
|
pub decos: SpanVec<Deco>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Feedback {
|
impl Feedback {
|
||||||
/// Create a new feedback instance without errors and decos.
|
/// Create a new feedback instance without errors and decos.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { diagnostics: vec![], decorations: vec![] }
|
Self { diags: vec![], decos: vec![] }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merged two feedbacks into one.
|
/// Merged two feedbacks into one.
|
||||||
@ -116,14 +116,14 @@ impl Feedback {
|
|||||||
|
|
||||||
/// Add other feedback data to this feedback.
|
/// Add other feedback data to this feedback.
|
||||||
pub fn extend(&mut self, more: Self) {
|
pub fn extend(&mut self, more: Self) {
|
||||||
self.diagnostics.extend(more.diagnostics);
|
self.diags.extend(more.diags);
|
||||||
self.decorations.extend(more.decorations);
|
self.decos.extend(more.decos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add more feedback whose spans are local and need to be offset by an
|
/// Add more feedback whose spans are local and need to be offset by an
|
||||||
/// `offset` to be correct in this feedback's context.
|
/// `offset` to be correct in this feedback's context.
|
||||||
pub fn extend_offset(&mut self, more: Self, offset: Pos) {
|
pub fn extend_offset(&mut self, more: Self, offset: Pos) {
|
||||||
self.diagnostics.extend(more.diagnostics.offset(offset));
|
self.diags.extend(more.diags.offset(offset));
|
||||||
self.decorations.extend(more.decorations.offset(offset));
|
self.decos.extend(more.decos.offset(offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,12 @@ macro_rules! std {
|
|||||||
/// Create a scope with all standard library functions.
|
/// Create a scope with all standard library functions.
|
||||||
pub fn _std() -> Scope {
|
pub fn _std() -> Scope {
|
||||||
let mut std = Scope::new();
|
let mut std = Scope::new();
|
||||||
$(std.insert($name, wrap!($func));)*
|
$(std.set($name, ValueFunc::new(|args, ctx| Box::pin($func(args, ctx))));)*
|
||||||
std
|
std
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! wrap {
|
|
||||||
($func:expr) => {
|
|
||||||
ValueFunc::new(|args, ctx| Box::pin($func(args, ctx)))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
std! {
|
std! {
|
||||||
"align" => align,
|
"align" => align,
|
||||||
"box" => boxed,
|
"box" => boxed,
|
||||||
|
@ -246,7 +246,7 @@ fn dict_contents(p: &mut Parser) -> (LitDict, bool) {
|
|||||||
|
|
||||||
if let Some(key) = &entry.key {
|
if let Some(key) = &entry.key {
|
||||||
comma_and_keyless = false;
|
comma_and_keyless = false;
|
||||||
p.deco(Decoration::DictKey.span_with(key.span));
|
p.deco(Deco::DictKey.span_with(key.span));
|
||||||
}
|
}
|
||||||
|
|
||||||
let behind = entry.expr.span.end;
|
let behind = entry.expr.span.end;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
use super::{Scanner, TokenMode, Tokens};
|
use super::{Scanner, TokenMode, Tokens};
|
||||||
use crate::diagnostic::Diagnostic;
|
use crate::diag::Diag;
|
||||||
use crate::syntax::{Decoration, Pos, Span, SpanWith, Spanned, Token};
|
use crate::syntax::{Deco, Pos, Span, SpanWith, Spanned, Token};
|
||||||
use crate::Feedback;
|
use crate::Feedback;
|
||||||
|
|
||||||
/// A convenient token-based parser.
|
/// A convenient token-based parser.
|
||||||
@ -34,8 +34,8 @@ impl<'s> Parser<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a diagnostic to the feedback.
|
/// Add a diagnostic to the feedback.
|
||||||
pub fn diag(&mut self, diag: Spanned<Diagnostic>) {
|
pub fn diag(&mut self, diag: Spanned<Diag>) {
|
||||||
self.f.diagnostics.push(diag);
|
self.f.diags.push(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Eat the next token and add a diagnostic that it was not the expected
|
/// Eat the next token and add a diagnostic that it was not the expected
|
||||||
@ -66,8 +66,8 @@ impl<'s> Parser<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a decoration to the feedback.
|
/// Add a decoration to the feedback.
|
||||||
pub fn deco(&mut self, deco: Spanned<Decoration>) {
|
pub fn deco(&mut self, deco: Spanned<Deco>) {
|
||||||
self.f.decorations.push(deco);
|
self.f.decos.push(deco);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the token mode and push the previous mode onto a stack.
|
/// Update the token mode and push the previous mode onto a stack.
|
||||||
|
@ -12,7 +12,7 @@ use crate::syntax::*;
|
|||||||
|
|
||||||
// ------------------------------ Construct Syntax Nodes ------------------------------ //
|
// ------------------------------ Construct Syntax Nodes ------------------------------ //
|
||||||
|
|
||||||
use Decoration::*;
|
use Deco::*;
|
||||||
use SynNode::{Emph as E, Linebreak as L, Parbreak as P, Space as S, Strong as B};
|
use SynNode::{Emph as E, Linebreak as L, Parbreak as P, Space as S, Strong as B};
|
||||||
|
|
||||||
fn T(text: &str) -> SynNode {
|
fn T(text: &str) -> SynNode {
|
||||||
@ -160,7 +160,7 @@ macro_rules! e {
|
|||||||
($src:expr => $($tts:tt)*) => {
|
($src:expr => $($tts:tt)*) => {
|
||||||
let exp = vec![$($tts)*];
|
let exp = vec![$($tts)*];
|
||||||
let pass = parse($src);
|
let pass = parse($src);
|
||||||
let found = pass.feedback.diagnostics.iter()
|
let found = pass.feedback.diags.iter()
|
||||||
.map(|s| s.as_ref().map(|e| e.message.as_str()))
|
.map(|s| s.as_ref().map(|e| e.message.as_str()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
check($src, exp, found, true);
|
check($src, exp, found, true);
|
||||||
@ -172,7 +172,7 @@ macro_rules! d {
|
|||||||
($src:expr => $($tts:tt)*) => {
|
($src:expr => $($tts:tt)*) => {
|
||||||
let exp = vec![$($tts)*];
|
let exp = vec![$($tts)*];
|
||||||
let pass = parse($src);
|
let pass = parse($src);
|
||||||
check($src, exp, pass.feedback.decorations, true);
|
check($src, exp, pass.feedback.decos, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use crate::eval::{Dict, Value, ValueDict};
|
pub use crate::eval::{Dict, Value, ValueDict};
|
||||||
pub use crate::layout::primitive::*;
|
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use crate::layout::{layout_tree, Command, LayoutContext};
|
pub use crate::layout::{layout_tree, primitive::*, Command, LayoutContext};
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use crate::syntax::{Span, Spanned, SynTree};
|
pub use crate::syntax::{Span, Spanned, SynTree};
|
||||||
pub use crate::{Feedback, Pass};
|
pub use crate::{Feedback, Pass};
|
||||||
|
@ -15,7 +15,7 @@ pub use token::*;
|
|||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
||||||
pub enum Decoration {
|
pub enum Deco {
|
||||||
/// Emphasized text.
|
/// Emphasized text.
|
||||||
Emph,
|
Emph,
|
||||||
/// Strong text.
|
/// Strong text.
|
||||||
|
@ -74,25 +74,24 @@ fn test(name: &str, src: &str, src_path: &Path, loader: &SharedFontLoader) {
|
|||||||
let state = State::default();
|
let state = State::default();
|
||||||
let Pass {
|
let Pass {
|
||||||
output: layouts,
|
output: layouts,
|
||||||
feedback: Feedback { mut diagnostics, .. },
|
feedback: Feedback { mut diags, .. },
|
||||||
} = block_on(typeset(&src, state, Rc::clone(loader)));
|
} = block_on(typeset(&src, state, Rc::clone(loader)));
|
||||||
|
|
||||||
if !diagnostics.is_empty() {
|
if !diags.is_empty() {
|
||||||
diagnostics.sort();
|
diags.sort();
|
||||||
|
|
||||||
let map = LineMap::new(&src);
|
let map = LineMap::new(&src);
|
||||||
for diagnostic in diagnostics {
|
for diag in diags {
|
||||||
let span = diagnostic.span;
|
let span = diag.span;
|
||||||
let start = map.location(span.start);
|
let start = map.location(span.start);
|
||||||
let end = map.location(span.end);
|
let end = map.location(span.end);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
" {}: {}:{}-{}: {}",
|
" {}: {}:{}-{}: {}",
|
||||||
diagnostic.v.level,
|
diag.v.level,
|
||||||
src_path.display(),
|
src_path.display(),
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
diagnostic.v.message,
|
diag.v.message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user