carpentries / carpentries/pegboard

Clean up process for adding new nodes

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
6
Forks
5
PR merge metrics
No merged PRs in 30d

Description

There are several places in the code where I add new nodes that need to be cleaned up, because there are so many different ways of doing it, but in reality, all I need to do is to add a node with the same namespace.

### Path forward

Some relevant material is at https://github.com/ropenscilabs/tinkr/pull/24 is relevant material here, but an idea is that we have a general node generator that could look like:

```r
make_node <- function(type, ..., ns = "http://commonmark.org/xml/1.0") glue::glue("<{type} {paste(..., collapse = ' ')}>")
p <- make_node("paragraph")
txt <- make_node("text")
xml2::xml_set_text(txt, "hello there")
xml2::xml_add_child(p, txt)

code <- make_node("code_block", "language='r'", "name='setup'", "eval=FALSE")
xml2::xml_set_text(code, "a <- 1:10\n")
```

#### Relevant places in the code

https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/utils.R#L66
~~https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/utils.R#L76~~
~~https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/utils.R#L106~~
~~https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/utils.R#L126~~
https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/fix_links.R#L41
https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/div.R#L18
https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/div.R#L274
https://github.com/carpentries/pegboard/blob/f2155d3a5e6b94ff677fdf2daeed9562458e6085/R/div.R#L349

Contributor guide

Open the contributing guide

Research direction

Start by reading the node-construction code in R/utils.R, R/fix_links.R, and R/div.R, then review the linked tinkr pull request for related context. Trace the different ways nodes are created and identify the shared namespace behavior. Done means the relevant callers use a consistent node-generation approach without changing their existing results.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.