Skip to content

Commit

Permalink
[doc/ref] Update methods, e.g. Dict.accum() and clear()
Browse files Browse the repository at this point in the history
We're missing substring search, e.g. mystr.find('foo') and so forth
  • Loading branch information
Andy C committed Nov 7, 2024
1 parent 185c077 commit 54b7657
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
10 changes: 10 additions & 0 deletions doc/ref/chap-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ The name `append` can refer to:
[cmd/append]: chap-builtin-cmd.html#cmd/append
[List/append]: chap-type-method.html#List/append

### clear

The name `clear` can refer to:

- The [List method clear][List/clear]
- The [Dict method clear][Dict/clear]

[List/clear]: chap-type-method.html#List/clear
[Dict/clear]: chap-type-method.html#Dict/clear

### false

The name `false` can refer to:
Expand Down
29 changes: 24 additions & 5 deletions doc/ref/chap-type-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,19 @@ An `Obj` instance representing the string type.

### find()

TODO
TODO:

var i = mystr.find('foo')

Similar to

= 'foo' in mystr

Both of them do substring search.

Also similar to `mystr.search(eggex)`.

<!-- Python also has start, end indices, to reduce allocations -->

### replace()

Expand Down Expand Up @@ -453,7 +465,7 @@ Reverses a list in place.
call fruits->reverse()
echo @fruits # => pear banana apple

### clear()
### List/clear()

TODO:

Expand Down Expand Up @@ -489,11 +501,18 @@ Ensures that the given key does not exist in the dictionary.
= book
# => (Dict) {title: "The Histories"}

### Dict/append()
### accum()

TODO:

call mydict->accum('key', 'string to append')

Similar:

setvar mydict['k'] += 3 # TODO: default value of 0

TODO

### clear()
### Dict/clear()

TODO:

Expand Down
21 changes: 11 additions & 10 deletions doc/ref/toc-ysh.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,31 @@ error handling, and more.
Float
Range
[String] Str X find() replace()
trim() trimStart() trimEnd()
trim() trimStart() trimEnd()
startsWith() endsWith()
upper() lower()
search() leftMatch()
split()
[Patterns] Eggex
Match group() start() end()
Match group() start() end()
X groups() X groupDict()
[Containers] List List/append() pop() extend()
indexOf() X insert() X remove()
reverse() X clear()
Dict erase() X clear() X Dict/append()
[Containers] List List/append() pop() extend()
indexOf() X insert() X remove()
reverse() X List/clear()
Dict erase() X Dict/clear() X accum()
Place setValue()
[Code Types] Func BuiltinFunc BoundFunc
Proc BuiltinProc
[Objects] Obj __invoke__ new
X __call__ __index__ X __str__
X __call__ __index__ X __str__
[Reflection] Command CommandFrag
Expr
Frame
io stdin evalExpr()
eval() evalToDict() captureStdout()
eval() evalToDict()
captureStdout()
promptVal()
X time() X strftime() X glob()
X time() X strftime() X glob()
vm getFrame() id()
```

Expand All @@ -89,7 +91,6 @@ error handling, and more.
[Word] glob() maybe()
[Serialize] toJson() fromJson()
toJson8() fromJson8()
X [J8 Decode] J8.Bool() J8.Int() ...
[Pattern] _group() _start() _end()
[Introspection] shvarGet() getVar() setVar()
parseCommand() X parseExpr() X bindFrame()
Expand Down

0 comments on commit 54b7657

Please sign in to comment.