## ----setup-0, include = FALSE-------------------------------------------------
message("current_input: ", knitr::current_input(dir = TRUE))
message("getwd: ", getwd())
message("vig_dir would be: ", dirname(knitr::current_input(dir = TRUE)))

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse  = TRUE,
  comment   = "#>",
  eval      = FALSE,
  out.width = "40%"
)
library(toolero)

# Build absolute paths to figures using this vignette file's location.
# knitr::current_input(dir = TRUE) returns the absolute path to the
# currently executing vignette regardless of the working directory,
# which varies between interactive knitting and R CMD check.
vig_dir <- dirname(knitr::current_input(dir = TRUE))
fig_dir  <- file.path(vig_dir, "figures")

## ----simple-np, eval = FALSE--------------------------------------------------
# arborize(
#   "[NP [Det the] [N cat]]",
#   output    = "figures/np-tree.png",
#   papersize = "a6",
#   margin    = "0.5cm"
# )

## ----echo=FALSE, eval=TRUE, out.width="30%"-----------------------------------
knitr::include_graphics("figures/np-tree.png")

## ----clause, eval = FALSE-----------------------------------------------------
# arborize(
#   "[S [NP [Det the] [N cat]] [VP [V chased] [NP [Det the] [N dog]]]]",
#   output    = "figures/clause-tree.png",
#   papersize = "a5",
#   margin    = "0.5cm"
# )

## ----echo=FALSE, eval=TRUE, out.width="55%"-----------------------------------
knitr::include_graphics("figures/clause-tree.png")

## ----aspectual, eval = FALSE--------------------------------------------------
# arborize(
#   paste0(
#     "[Aspectual Classes ",
#     "[Statives [States]] ",
#     "[Dynamic ",
#     "[Atelic [Activities]] ",
#     "[Telic ",
#     "[Instantaneous [Achievements]] ",
#     "[Durative [Accomplishments]]]]]"
#   ),
#   output    = "figures/aspectual-classes.png",
#   papersize = "a4",
#   margin    = "1cm",
#   dpi       = 300
# )

## ----echo=FALSE, eval=TRUE, out.width="80%"-----------------------------------
knitr::include_graphics("figures/aspectual-classes.png")

## ----print-quality, eval = FALSE----------------------------------------------
# arborize(
#   "[NP [Det the] [N cat]]",
#   output    = "figures/np-tree-hires.png",
#   papersize = "a6",
#   margin    = "0.5cm",
#   dpi       = 600
# )

## ----tight-crop, eval = FALSE-------------------------------------------------
# arborize(
#   "[NP [Det the] [N cat]]",
#   output    = "figures/np-tree-tight.png",
#   papersize = "a6",
#   margin    = "0.1cm"
# )

## ----echo=FALSE, eval=TRUE, out.width="25%"-----------------------------------
knitr::include_graphics("figures/np-tree-tight.png")

## ----lingotree, eval = FALSE--------------------------------------------------
# arborize(
#   "tree(
#     tag: [VP],
#     tree(
#       tag: [DP],
#       [every],
#       [farmer]
#     ),
#     [smiled]
#   )",
#   tree_notation = "structured",
#   output        = "figures/vp-lingotree.png",
#   papersize     = "a6",
#   margin        = "0.5cm"
# )

## ----echo=FALSE, eval=TRUE, out.width="30%"-----------------------------------
knitr::include_graphics("figures/vp-lingotree.png")

## ----no-provenance, eval = FALSE----------------------------------------------
# arborize(
#   "[NP [Det the] [N cat]]",
#   output     = "figures/np-tree.png",
#   papersize  = "a6",
#   provenance = FALSE
# )

## ----provenance-demo, eval = FALSE--------------------------------------------
# arborize(
#   "[NP [Det the] [N cat]]",
#   output    = "figures/np-tree.png",
#   papersize = "a6",
#   margin    = "0.5cm"
# )

## ----rearborize, eval = FALSE-------------------------------------------------
# p <- yaml::read_yaml("figures/np-tree.yaml")
# 
# arborize(
#   tree          = p$tree,
#   output        = "figures/np-tree-hires.png",
#   dpi           = 600,
#   tree_notation = p$tree_notation,
#   papersize     = p$papersize,
#   margin        = p$margin,
#   overwrite     = TRUE
# )

