Skip to content

Commit d9103c0

Browse files
authored
Update docs (#29)
* Run python docs/scripts/build_docs.py * update docs to specify how to install ruby
1 parent 09da405 commit d9103c0

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

docs/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,23 @@ To convert images to webp, run this from the project root:
1717
```bash
1818
# convert docs/assets/images/examples
1919
python docs/scripts/convert_to_webp.py -d docs/assets/images/examples --height 400
20+
```
21+
22+
## Run
23+
24+
The weblinx homepage is built with jekyll, which uses ruby. If you do not have ruby installed, please install it, then install bundler:
25+
```bash
26+
# Install ruby and gem
27+
sudo apt-get install ruby-dev
28+
29+
# install bundler
30+
gem install bundler -v 2.4.22
31+
```
32+
33+
to run it locally, run this from the project root:
34+
35+
```bash
36+
cd docs
37+
bundle install
38+
bundle exec jekyll serve
2039
```

docs/_docs/weblinx.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Generate a __repr__ method for a class with the given attributes
1919
### `Demonstration`
2020

2121
```
22-
weblinx.Demonstration(name, base_dir="./demonstrations", json_backend="auto")
22+
weblinx.Demonstration(name, base_dir="./demonstrations", json_backend="auto", encoding=None)
2323
```
2424

2525
#### Description
@@ -33,6 +33,7 @@ weblinx.Demonstration(name, base_dir="./demonstrations", json_backend="auto")
3333
| `name` | `str` | | Name of the demonstration directory |
3434
| `base_dir` | `str` | `"./demonstrations"` | Base directory containing all demonstrations directories |
3535
| `json_backend` | `str` | `"auto"` | Backend to use to load JSON files. Can be either 'auto', 'json', 'orjson', or 'ujson'. For the 'auto' option, it will try to import 'orjson' first, then 'ujson', then 'json'. Both 'orjson' and 'ujson' are faster than 'json', but they must be installed first, via `pip install orjson` or `pip install ujson`. |
36+
| `encoding` | `str` | `None` | Encoding to use when reading and writing files. If None, it will use the system's default encoding. |
3637

3738

3839
#### `Demonstration.__repr__`
@@ -126,7 +127,7 @@ checking that all required files exist.
126127
#### `Demonstration.load_json`
127128

128129
```
129-
weblinx.Demonstration.load_json(self, filename, backend=None, default=None)
130+
weblinx.Demonstration.load_json(self, filename, backend=None, default=None, encoding=None)
130131
```
131132

132133
##### Description
@@ -141,6 +142,7 @@ Load a JSON file from the demonstration directory
141142
| `filename` | `str` | | Name of the file to load |
142143
| `backend` | `str` | `None` | Backend to use to load the JSON file. Can be either None, 'auto', 'json', 'orjson', or 'ujson'. If 'auto', it will try to import 'orjson' first, then 'ujson', then 'json'. If None, it will use the json_backend specified in the constructor. |
143144
| `default` | `Any` | `None` | Default value to return if the file does not exist. If None, it will raise an error. |
145+
| `encoding` | `str` | `None` | Encoding to use when reading the file. If None, it will default to the Demonstration's encoding specified in the constructor, or the system's default encoding if it was not specified. |
144146

145147

146148
#### `Demonstration.save_json`
@@ -254,7 +256,7 @@ html_path = demo.join('pages', 'page-1-0.html')
254256
### `Turn`
255257

256258
```
257-
weblinx.Turn(turn_dict, index, demo_name, base_dir, json_backend="auto")
259+
weblinx.Turn(turn_dict, index, demo_name, base_dir, json_backend="auto", encoding=None)
258260
```
259261

260262
#### Description
@@ -764,7 +766,7 @@ A string indicating the screenshot status ('good', 'broken', or None).
764766
#### `Turn.get_xpaths_dict`
765767

766768
```
767-
weblinx.Turn.get_xpaths_dict(self, uid_key="data-webtasks-id", cache_dir=None, allow_save=True, check_hash=False, parser="lxml", json_backend="auto")
769+
weblinx.Turn.get_xpaths_dict(self, uid_key="data-webtasks-id", cache_dir=None, allow_save=True, check_hash=False, parser="lxml", json_backend="auto", encoding=None)
768770
```
769771

770772
##### Description
@@ -785,6 +787,7 @@ before using cached data.
785787
| `check_hash` | `bool` | `False` | Whether to validate the HTML hash before using cached XPaths. |
786788
| `parser` | `str` | `"lxml"` | The parser backend to use for HTML parsing. Currently, only 'lxml' is supported. |
787789
| `json_backend` | `str` | `"auto"` | The backend to use for loading and saving JSON. If 'auto', chooses the best available option. |
790+
| `encoding` | `str` | `None` | Encoding to use when reading the file. If None, it will default to the Demonstration's encoding specified in the constructor, or the system's default encoding if it was not specified. |
788791

789792

790793
##### Returns
@@ -798,7 +801,7 @@ A dictionary mapping unique IDs (from `uid_key`) to their corresponding XPaths i
798801
### `Replay`
799802

800803
```
801-
weblinx.Replay(replay_json, demo_name, base_dir)
804+
weblinx.Replay(replay_json, demo_name, base_dir, encoding=None)
802805
```
803806

804807
#### Description
@@ -813,6 +816,7 @@ Represents a replay of a demonstration, encapsulating a sequence of turns (actio
813816
| `replay_json` | `dict` | | The JSON object containing the replay data. |
814817
| `demo_name` | `str` | | The name of the demonstration this replay belongs to. |
815818
| `base_dir` | `str` | | The base directory where the demonstration data is stored. |
819+
| `encoding` | `str` | `None` | The encoding to use when reading files. If None, it will default to the system's default encoding. |
816820

817821

818822
#### `Replay.__getitem__`

docs/_docs/weblinx/processing.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ The utterances formatted as a string, or as a list if sep is None.
619619
### `format_prev_turns_truncated`
620620

621621
```
622-
weblinx.processing.prompt.format_prev_turns_truncated(replay, turn, format_intent, tokenizer, num_tokens_to_remove, format_output_dict_fn=<_ast.Name object at 0x7feace0b3f40>, num_prev_turns=5, turn_sep=" ; ", allow_iterative_reduction=False)
622+
weblinx.processing.prompt.format_prev_turns_truncated(replay, turn, format_intent, tokenizer, num_tokens_to_remove, format_output_dict_fn=<_ast.Name object at 0x7fac2032a370>, num_prev_turns=5, turn_sep=" ; ", allow_iterative_reduction=False)
623623
```
624624

625625
#### Description
@@ -648,7 +648,7 @@ This output of this function should be used by format_utterances to display the
648648
### `multi_attempt_format_prev_turns_truncated`
649649

650650
```
651-
weblinx.processing.prompt.multi_attempt_format_prev_turns_truncated(replay, turn, format_intent, tokenizer, max_tokens, num_prev_turns=5, turn_sep=" ; ", max_attempts=5, format_output_dict_fn=<_ast.Name object at 0x7feace024dc0>, warn_after_attempts=True, allow_iterative_reduction=False)
651+
weblinx.processing.prompt.multi_attempt_format_prev_turns_truncated(replay, turn, format_intent, tokenizer, max_tokens, num_prev_turns=5, turn_sep=" ; ", max_attempts=5, format_output_dict_fn=<_ast.Name object at 0x7fac2034a2b0>, warn_after_attempts=True, allow_iterative_reduction=False)
652652
```
653653

654654
#### Description
@@ -737,7 +737,7 @@ The top candidates for the given turn.
737737
### `select_turns_and_candidates_for_prompts`
738738

739739
```
740-
weblinx.processing.prompt.select_turns_and_candidates_for_prompts(demos, candidates=None, num_candidates=20)
740+
weblinx.processing.prompt.select_turns_and_candidates_for_prompts(demos, candidates=None, num_candidates=20, remove_turns_without_elements=True)
741741
```
742742

743743
#### Description
@@ -756,6 +756,7 @@ for a given turn, then we will find the previous turn that has candidates.
756756
| `demos` | `list` | | The list of demonstrations to select the turns from. |
757757
| `candidates` | `dict` | `None` | The candidates for all turns, as a dictionary of lists. If None, then the candidates will not be used. Defaults to None. |
758758
| `num_candidates` | `int` | `20` | The number of candidates to select for each turn. Defaults to 20. |
759+
| `remove_turns_without_elements` | `bool` | `True` | Whether to remove turns that do not have elements. Defaults to True. |
759760

760761

761762
#### Returns

docs/_docs/weblinx/utils.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ not None, then this will be a random sample of the specified size.
125125
### `auto_read_json`
126126

127127
```
128-
weblinx.utils.auto_read_json(path, backend="auto")
128+
weblinx.utils.auto_read_json(path, backend="auto", encoding=None)
129129
```
130130

131131
### `auto_save_json`
132132

133133
```
134-
weblinx.utils.auto_save_json(data, path, backend="auto", indent=None)
134+
weblinx.utils.auto_save_json(data, path, backend="auto", indent=0)
135135
```
136136

137137
### `save_results`
@@ -560,7 +560,7 @@ A string or dictionary representing the timestamp.
560560
### `format_change`
561561

562562
```
563-
weblinx.utils.format.format_change(turn, formatters=(<_ast.Name object at 0x7feacdfde4c0>, <_ast.Name object at 0x7feacdfde5b0>, <_ast.Name object at 0x7feacdfde5e0>), return_as="dict")
563+
weblinx.utils.format.format_change(turn, formatters=(<_ast.Name object at 0x7fac2032da60>, <_ast.Name object at 0x7fac2032db50>, <_ast.Name object at 0x7fac2032db80>), return_as="dict")
564564
```
565565

566566
#### Description
@@ -577,7 +577,7 @@ when the input is changed, for example, in an input, select or textarea.
577577
| Name | Type | Default | Description |
578578
| ---- | ---- | ------- | ----------- |
579579
| `turn` | `Turn` | | The turn object to be represented as either a string or a dictionary. |
580-
| `formatters` | `` | `(<_ast.Name object at 0x7feacdfde4c0>, <_ast.Name object at 0x7feacdfde5b0>, <_ast.Name object at 0x7feacdfde5e0>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
580+
| `formatters` | `` | `(<_ast.Name object at 0x7fac2032da60>, <_ast.Name object at 0x7fac2032db50>, <_ast.Name object at 0x7fac2032db80>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
581581
| `return_as` | `str` | `"dict"` | Whether to return the formatted element as a string or a dictionary. |
582582

583583

@@ -592,7 +592,7 @@ A string or dictionary representing the turn.
592592
### `format_click`
593593

594594
```
595-
weblinx.utils.format.format_click(turn, formatters=(<_ast.Name object at 0x7feacdfdecd0>, <_ast.Name object at 0x7feacdfdec70>, <_ast.Name object at 0x7feace01d040>), return_as="dict")
595+
weblinx.utils.format.format_click(turn, formatters=(<_ast.Name object at 0x7fac2032a610>, <_ast.Name object at 0x7fac2032a520>, <_ast.Name object at 0x7fac2032a670>), return_as="dict")
596596
```
597597

598598
#### Description
@@ -605,7 +605,7 @@ Format a turn with intent click into a readable format.
605605
| Name | Type | Default | Description |
606606
| ---- | ---- | ------- | ----------- |
607607
| `turn` | `Turn` | | The turn object to be represented as either a string or a dictionary. |
608-
| `formatters` | `` | `(<_ast.Name object at 0x7feacdfdecd0>, <_ast.Name object at 0x7feacdfdec70>, <_ast.Name object at 0x7feace01d040>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
608+
| `formatters` | `` | `(<_ast.Name object at 0x7fac2032a610>, <_ast.Name object at 0x7fac2032a520>, <_ast.Name object at 0x7fac2032a670>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
609609
| `return_as` | `str` | `"dict"` | Whether to return the formatted element as a string or a dictionary. |
610610

611611

@@ -678,7 +678,7 @@ A string or dictionary representing the turn.
678678
### `format_hover`
679679

680680
```
681-
weblinx.utils.format.format_hover(turn, formatters=(<_ast.Name object at 0x7feace004a90>, <_ast.Name object at 0x7feace004ac0>, <_ast.Name object at 0x7feace004af0>), return_as="dict")
681+
weblinx.utils.format.format_hover(turn, formatters=(<_ast.Name object at 0x7fac20343040>, <_ast.Name object at 0x7fac20343070>, <_ast.Name object at 0x7fac203430a0>), return_as="dict")
682682
```
683683

684684
#### Description
@@ -691,7 +691,7 @@ This behaves similarly to format_click, but for hover events.
691691
| Name | Type | Default | Description |
692692
| ---- | ---- | ------- | ----------- |
693693
| `turn` | `Turn` | | The turn object to be represented as either a string or a dictionary. |
694-
| `formatters` | `list or tuple` | `(<_ast.Name object at 0x7feace004a90>, <_ast.Name object at 0x7feace004ac0>, <_ast.Name object at 0x7feace004af0>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
694+
| `formatters` | `list or tuple` | `(<_ast.Name object at 0x7fac20343040>, <_ast.Name object at 0x7fac20343070>, <_ast.Name object at 0x7fac203430a0>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
695695
| `return_as` | `str` | `"dict"` | Whether to return the formatted element as a string or a dictionary. |
696696

697697

@@ -807,7 +807,7 @@ Similar to format_mouse_xy, but for scroll events.
807807
### `format_submit`
808808
809809
```
810-
weblinx.utils.format.format_submit(turn, formatters=(<_ast.Name object at 0x7feace0245b0>, <_ast.Name object at 0x7feace0245e0>), return_as="dict")
810+
weblinx.utils.format.format_submit(turn, formatters=(<_ast.Name object at 0x7fac20160b20>, <_ast.Name object at 0x7fac20160b50>), return_as="dict")
811811
```
812812
813813
#### Description
@@ -820,7 +820,7 @@ Format a turn with intent submit into a readable format.
820820
| Name | Type | Default | Description |
821821
| ---- | ---- | ------- | ----------- |
822822
| `turn` | `Turn` | | The turn object to be represented as either a string or a dictionary. |
823-
| `formatters` | `` | `(<_ast.Name object at 0x7feace0245b0>, <_ast.Name object at 0x7feace0245e0>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
823+
| `formatters` | `` | `(<_ast.Name object at 0x7fac20160b20>, <_ast.Name object at 0x7fac20160b50>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
824824
| `return_as` | `str` | `"dict"` | Whether to return the formatted element as a string or a dictionary. |
825825
826826
@@ -837,7 +837,7 @@ Format a turn with intent tabcreate, tabremove or tabswitch into a readable form
837837
### `format_text_input`
838838
839839
```
840-
weblinx.utils.format.format_text_input(turn, formatters=(<_ast.Name object at 0x7feace033ca0>, <_ast.Name object at 0x7feace033df0>, <_ast.Name object at 0x7feace033f10>), return_as="dict")
840+
weblinx.utils.format.format_text_input(turn, formatters=(<_ast.Name object at 0x7fac20152220>, <_ast.Name object at 0x7fac20152340>, <_ast.Name object at 0x7fac20152490>), return_as="dict")
841841
```
842842
843843
#### Description
@@ -854,7 +854,7 @@ is changed.
854854
| Name | Type | Default | Description |
855855
| ---- | ---- | ------- | ----------- |
856856
| `turn` | `Turn` | | The turn object to be represented as either a string or a dictionary. |
857-
| `formatters` | `` | `(<_ast.Name object at 0x7feace033ca0>, <_ast.Name object at 0x7feace033df0>, <_ast.Name object at 0x7feace033f10>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
857+
| `formatters` | `` | `(<_ast.Name object at 0x7fac20152220>, <_ast.Name object at 0x7fac20152340>, <_ast.Name object at 0x7fac20152490>)` | A tuple of functions to be used to format the turn. The functions will be called in order, and each function should return a dictionary (not a string), which will be merged into the final output. The functions should take the turn as the first argument, and return a dictionary. |
858858
| `return_as` | `str` | `"dict"` | Whether to return the formatted element as a string or a dictionary. |
859859
860860
@@ -869,7 +869,7 @@ A string or dictionary representing the turn.
869869
### `format_intent_automatically`
870870
871871
```
872-
weblinx.utils.format.format_intent_automatically(turn, format_change=<_ast.Name object at 0x7feace039c40>, format_click=<_ast.Name object at 0x7feace039c70>, format_copy=<_ast.Name object at 0x7feace039ca0>, format_hover=<_ast.Name object at 0x7feace039cd0>, format_load=<_ast.Name object at 0x7feace039d00>, format_paste=<_ast.Name object at 0x7feace039d30>, format_say=<_ast.Name object at 0x7feace039d60>, format_scroll=<_ast.Name object at 0x7feace039d90>, format_submit=<_ast.Name object at 0x7feace039dc0>, format_tab=<_ast.Name object at 0x7feace039df0>, format_text_input=<_ast.Name object at 0x7feace039e20>, return_as="dict")
872+
weblinx.utils.format.format_intent_automatically(turn, format_change=<_ast.Name object at 0x7fac201621f0>, format_click=<_ast.Name object at 0x7fac20162220>, format_copy=<_ast.Name object at 0x7fac20162250>, format_hover=<_ast.Name object at 0x7fac20162280>, format_load=<_ast.Name object at 0x7fac201622b0>, format_paste=<_ast.Name object at 0x7fac201622e0>, format_say=<_ast.Name object at 0x7fac20162310>, format_scroll=<_ast.Name object at 0x7fac20162340>, format_submit=<_ast.Name object at 0x7fac20162370>, format_tab=<_ast.Name object at 0x7fac201623a0>, format_text_input=<_ast.Name object at 0x7fac201623d0>, return_as="dict")
873873
```
874874
875875
#### Description

0 commit comments

Comments
 (0)