Skip to content

Commit 855a9ff

Browse files
CWood-sdfgithub-actions[bot]
authored andcommitted
chore(build): auto-generate docs
1 parent 9196dd8 commit 855a9ff

File tree

3 files changed

+192
-2
lines changed

3 files changed

+192
-2
lines changed

doc/banana-ast.txt

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ Table of Contents *banana-ast-table-of-contents*
4747
- appendTextNode |banana-ast-appendtextnode|
4848
- appendTextNodeNoEscape |banana-ast-appendtextnodenoescape|
4949
- appendChild |banana-ast-appendchild|
50+
- isLineHovering |banana-ast-islinehovering|
51+
- isHovering |banana-ast-ishovering|
52+
- removeChildren |banana-ast-removechildren|
53+
- children |banana-ast-children|
54+
- childIterWithI |banana-ast-childiterwithi|
55+
- allChildIter |banana-ast-allchilditer|
56+
- childIter |banana-ast-childiter|
57+
- child |banana-ast-child|
58+
- getAttributeSubstitution |banana-ast-getattributesubstitution|
59+
- getTextContent |banana-ast-gettextcontent|
60+
- setTextContent |banana-ast-settextcontent|
61+
- parent |banana-ast-parent|
62+
- isHidden |banana-ast-ishidden|
63+
- attachRemap |banana-ast-attachremap|
64+
- Explanation |banana-ast-explanation|
65+
- Constraints |banana-ast-constraints|
5066
1. Links |banana-ast-links|
5167
The AST class is the second of two API surfaces that you will use for any
5268
interaction with the dom tree in banana (the other one being Instance).
@@ -544,7 +560,165 @@ APPENDCHILD *banana-ast-appendchild*
544560

545561
Adds ast {node} as a child to this node
546562

547-
note: if you add a block element (eg
563+
note: if you add a block element (eg `<div>`) as a descendant of an inline
564+
element (eg `<span>`) you will get a LineTooBig error when trying to render
565+
566+
note: {node} CANNOT be a string
567+
568+
- **Parameters**:
569+
- `node` (Banana.Ast): the node to append as a child
570+
571+
572+
ISLINEHOVERING *banana-ast-islinehovering*
573+
574+
Returns true if the cursor is on the same line as this node
575+
576+
- **Returns**: `boolean`
577+
578+
579+
ISHOVERING *banana-ast-ishovering*
580+
581+
Returns true if the cursor is hovering over this ast
582+
583+
- **Returns**: `boolean`
584+
585+
586+
REMOVECHILDREN *banana-ast-removechildren*
587+
588+
Removes all children from this node (including text)
589+
590+
591+
CHILDREN *banana-ast-children*
592+
593+
Returns all ast node children of this element (not text nodes)
594+
595+
- **Returns**: `Banana.Ast[]`
596+
597+
598+
CHILDITERWITHI *banana-ast-childiterwithi*
599+
600+
Returns an iterator that allows iteration over all ast children with indexing
601+
602+
>lua
603+
for i, v in ast:childIterWithI() do
604+
end
605+
<
606+
607+
- **Returns**: `fun(): number?, Banana.Ast?`
608+
609+
610+
ALLCHILDITER *banana-ast-allchilditer*
611+
612+
Returns an iterator over all the children of this node (including text)
613+
614+
- **Returns**: `fun():(Banana.Ast|string)?`
615+
616+
617+
CHILDITER *banana-ast-childiter*
618+
619+
Returns an iterator over all the ast children of this node
620+
621+
- **Returns**: `fun():Banana.Ast?`
622+
623+
624+
CHILD *banana-ast-child*
625+
626+
Returns the nth non-string child of this node
627+
628+
- **Returns**: `Banana.Ast`
629+
630+
631+
GETATTRIBUTESUBSTITUTION *banana-ast-getattributesubstitution*
632+
633+
returns what the attribute substitution (eg %attr in nml) would be for {name}
634+
635+
>nml
636+
<div name="idk">
637+
<span id="1">%name</span> <!-- renders as "idk" -->
638+
</div>
639+
<
640+
641+
>lua
642+
document:getElementById("1"):getAttributeSubstitution("name") -- returns "idk"
643+
<
644+
645+
- **Parameters**:
646+
- `name` (string): the attribute to lookup
647+
- **Returns**: `string?`
648+
649+
650+
GETTEXTCONTENT *banana-ast-gettextcontent*
651+
652+
Returns the printed text value of this element (does not include newlines)
653+
654+
Note: This is currently bugged as entities (eg &) and attr substitutions (eg
655+
%attr) will not return their printed value
656+
657+
- **Returns**: `string`
658+
659+
660+
SETTEXTCONTENT *banana-ast-settextcontent*
661+
662+
Sets the text content of this element. Removes all other children
663+
664+
Replaces newlines with elements (note: if newlines are passed inside an inline
665+
element (eg. ), it will cause a LineTooBig error)
666+
667+
- **Parameters**:
668+
- `str` (string): the text to set this element’s content to
669+
670+
671+
PARENT *banana-ast-parent*
672+
673+
Returns the parent node of this node
674+
675+
- **Returns**: `Banana.Ast`
676+
677+
678+
ISHIDDEN *banana-ast-ishidden*
679+
680+
Returns true when this node is not rendered (eg the style `display: none`)
681+
682+
- **Returns**: `boolean`
683+
684+
685+
ATTACHREMAP *banana-ast-attachremap*
686+
687+
Attaches the given remap to the ast
688+
689+
690+
EXPLANATION *banana-ast-explanation*
691+
692+
For those wondering why one should not just use `vim.keymap.set` there are a
693+
few reasons.
694+
695+
1. Remap collision. `vim.keymap.set` can only set one remap per buffer which means that if you want multiple ast nodes to handle remaps differently (eg in mason when you try to install a package pressing `i` on different lines installs different packages) you have to have a central function handle everything. `attachRemap` allows "decentralized" remaps (ie each ast node can figure out how to best handle the remap)
696+
2. Remap deletion. Remembering to delete remap handlers when an ast is deleted can be annoying. Using `attachRemap` does that for you
697+
698+
699+
CONSTRAINTS *banana-ast-constraints*
700+
701+
Currently, the supported constraints are "hover", "line-hover", and <number>.
702+
703+
>lua
704+
-- this will only be called if the cursor is over the node (eg isHovering() is true)
705+
-- when the user types `<leader>w` or if the user types `1<leader>w`
706+
ast:attachRemap("n", "<leader>w", { "hover", 1 }, function()
707+
708+
end, {})
709+
<
710+
711+
Line-hover is similar to hover except that it calls the remap if the cursor is
712+
on the same line as the ast node (eg isLineHovering() is true), instead of
713+
strictly hovering over it
714+
715+
- **Parameters**:
716+
- `mode` (string): the mode of the keymap
717+
- `lhs` (string): the lhs of the keymap
718+
- `mods` (Banana.Remap.Constraint[]): a list of remap constraints
719+
- `rhs` (string|fun()): callback
720+
- `opts` (vim.keymap.set.Opts?): keymap options
721+
548722
==============================================================================
549723
1. Links *banana-ast-links*
550724

doc/banana-entities.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Table of Contents *banana-entities-table-of-contents*
55

66
Currently, banana supports the following named entities:
77

8+
- `&sp;`: ``
89
- `&lt;`: `<`
910
- `&gt;`: `>`
1011
- `&amp;`: `&`
1112
- `&lb;`: `{`
12-
- `&sp;`: ``
1313

1414
Banana also supports numerical entities (eg `&#32;` means space (character code
1515
32)). Currently, only decimal numbers are supported as the number

doc/tags

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
banana-ast-addclass banana-ast.txt /*banana-ast-addclass*
2+
banana-ast-allchilditer banana-ast.txt /*banana-ast-allchilditer*
23
banana-ast-appendchild banana-ast.txt /*banana-ast-appendchild*
34
banana-ast-appendtextnode banana-ast.txt /*banana-ast-appendtextnode*
45
banana-ast-appendtextnodenoescape banana-ast.txt /*banana-ast-appendtextnodenoescape*
56
banana-ast-asserthasstyle banana-ast.txt /*banana-ast-asserthasstyle*
7+
banana-ast-attachremap banana-ast.txt /*banana-ast-attachremap*
8+
banana-ast-child banana-ast.txt /*banana-ast-child*
9+
banana-ast-childiter banana-ast.txt /*banana-ast-childiter*
10+
banana-ast-childiterwithi banana-ast.txt /*banana-ast-childiterwithi*
11+
banana-ast-children banana-ast.txt /*banana-ast-children*
612
banana-ast-clone banana-ast.txt /*banana-ast-clone*
713
banana-ast-clonenode banana-ast.txt /*banana-ast-clonenode*
14+
banana-ast-constraints banana-ast.txt /*banana-ast-constraints*
15+
banana-ast-explanation banana-ast.txt /*banana-ast-explanation*
816
banana-ast-firstchild banana-ast.txt /*banana-ast-firstchild*
917
banana-ast-getattribute banana-ast.txt /*banana-ast-getattribute*
1018
banana-ast-getattributes banana-ast.txt /*banana-ast-getattributes*
19+
banana-ast-getattributesubstitution banana-ast.txt /*banana-ast-getattributesubstitution*
1120
banana-ast-getboundbox banana-ast.txt /*banana-ast-getboundbox*
1221
banana-ast-getcontext banana-ast.txt /*banana-ast-getcontext*
1322
banana-ast-getdata banana-ast.txt /*banana-ast-getdata*
1423
banana-ast-getheight banana-ast.txt /*banana-ast-getheight*
1524
banana-ast-getrootnode banana-ast.txt /*banana-ast-getrootnode*
1625
banana-ast-gettagname banana-ast.txt /*banana-ast-gettagname*
26+
banana-ast-gettextcontent banana-ast.txt /*banana-ast-gettextcontent*
1727
banana-ast-getwidth banana-ast.txt /*banana-ast-getwidth*
1828
banana-ast-hasattribute banana-ast.txt /*banana-ast-hasattribute*
1929
banana-ast-hasclass banana-ast.txt /*banana-ast-hasclass*
2030
banana-ast-hasstyle banana-ast.txt /*banana-ast-hasstyle*
2131
banana-ast-insertbefore banana-ast.txt /*banana-ast-insertbefore*
32+
banana-ast-ishidden banana-ast.txt /*banana-ast-ishidden*
33+
banana-ast-ishovering banana-ast.txt /*banana-ast-ishovering*
34+
banana-ast-islinehovering banana-ast.txt /*banana-ast-islinehovering*
2235
banana-ast-isnil banana-ast.txt /*banana-ast-isnil*
2336
banana-ast-lastchild banana-ast.txt /*banana-ast-lastchild*
2437
banana-ast-links banana-ast.txt /*banana-ast-links*
@@ -32,16 +45,19 @@ banana-ast-paddingbottom banana-ast.txt /*banana-ast-paddingbottom*
3245
banana-ast-paddingleft banana-ast.txt /*banana-ast-paddingleft*
3346
banana-ast-paddingright banana-ast.txt /*banana-ast-paddingright*
3447
banana-ast-paddingtop banana-ast.txt /*banana-ast-paddingtop*
48+
banana-ast-parent banana-ast.txt /*banana-ast-parent*
3549
banana-ast-previoussibling banana-ast.txt /*banana-ast-previoussibling*
3650
banana-ast-remove banana-ast.txt /*banana-ast-remove*
3751
banana-ast-removechild banana-ast.txt /*banana-ast-removechild*
52+
banana-ast-removechildren banana-ast.txt /*banana-ast-removechildren*
3853
banana-ast-removeclass banana-ast.txt /*banana-ast-removeclass*
3954
banana-ast-replacechild banana-ast.txt /*banana-ast-replacechild*
4055
banana-ast-setattribute banana-ast.txt /*banana-ast-setattribute*
4156
banana-ast-setdata banana-ast.txt /*banana-ast-setdata*
4257
banana-ast-setinnernml banana-ast.txt /*banana-ast-setinnernml*
4358
banana-ast-setstyle banana-ast.txt /*banana-ast-setstyle*
4459
banana-ast-setstylevalue banana-ast.txt /*banana-ast-setstylevalue*
60+
banana-ast-settextcontent banana-ast.txt /*banana-ast-settextcontent*
4561
banana-ast-table-of-contents banana-ast.txt /*banana-ast-table-of-contents*
4662
banana-ast-toggleclass banana-ast.txt /*banana-ast-toggleclass*
4763
banana-ast.txt banana-ast.txt /*banana-ast.txt*

0 commit comments

Comments
 (0)