kash-shell 0.3.17__py3-none-any.whl → 0.3.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. kash/actions/core/{markdownify.py → markdownify_html.py} +3 -6
  2. kash/actions/core/minify_html.py +41 -0
  3. kash/commands/base/show_command.py +11 -1
  4. kash/commands/workspace/workspace_commands.py +10 -88
  5. kash/config/colors.py +6 -2
  6. kash/docs/markdown/topics/a1_what_is_kash.md +52 -23
  7. kash/docs/markdown/topics/a2_installation.md +17 -30
  8. kash/docs/markdown/topics/a3_getting_started.md +5 -19
  9. kash/exec/__init__.py +3 -0
  10. kash/exec/action_exec.py +3 -3
  11. kash/exec/fetch_url_items.py +109 -0
  12. kash/exec/precondition_registry.py +3 -3
  13. kash/file_storage/file_store.py +24 -1
  14. kash/file_storage/store_filenames.py +4 -0
  15. kash/help/function_param_info.py +1 -1
  16. kash/help/help_pages.py +1 -1
  17. kash/help/help_printing.py +1 -1
  18. kash/llm_utils/llm_features.py +5 -1
  19. kash/llm_utils/llms.py +18 -8
  20. kash/media_base/media_cache.py +48 -24
  21. kash/media_base/media_services.py +63 -14
  22. kash/media_base/services/local_file_media.py +9 -1
  23. kash/model/items_model.py +22 -8
  24. kash/model/media_model.py +9 -1
  25. kash/model/params_model.py +9 -3
  26. kash/utils/common/function_inspect.py +97 -1
  27. kash/utils/common/parse_docstring.py +347 -0
  28. kash/utils/common/testing.py +58 -0
  29. kash/utils/common/url_slice.py +329 -0
  30. kash/utils/file_utils/file_formats.py +1 -1
  31. kash/utils/text_handling/markdown_utils.py +424 -16
  32. kash/web_content/web_extract.py +34 -15
  33. kash/web_content/web_page_model.py +10 -1
  34. kash/web_gen/templates/base_styles.css.jinja +137 -15
  35. kash/web_gen/templates/base_webpage.html.jinja +13 -17
  36. kash/web_gen/templates/components/toc_scripts.js.jinja +319 -0
  37. kash/web_gen/templates/components/toc_styles.css.jinja +284 -0
  38. kash/web_gen/templates/components/tooltip_scripts.js.jinja +730 -0
  39. kash/web_gen/templates/components/tooltip_styles.css.jinja +482 -0
  40. kash/web_gen/templates/content_styles.css.jinja +13 -8
  41. kash/web_gen/templates/simple_webpage.html.jinja +15 -481
  42. kash/workspaces/workspaces.py +10 -1
  43. {kash_shell-0.3.17.dist-info → kash_shell-0.3.20.dist-info}/METADATA +75 -72
  44. {kash_shell-0.3.17.dist-info → kash_shell-0.3.20.dist-info}/RECORD +47 -40
  45. kash/exec/fetch_url_metadata.py +0 -72
  46. kash/help/docstring_utils.py +0 -111
  47. {kash_shell-0.3.17.dist-info → kash_shell-0.3.20.dist-info}/WHEEL +0 -0
  48. {kash_shell-0.3.17.dist-info → kash_shell-0.3.20.dist-info}/entry_points.txt +0 -0
  49. {kash_shell-0.3.17.dist-info → kash_shell-0.3.20.dist-info}/licenses/LICENSE +0 -0
@@ -1,111 +0,0 @@
1
- from dataclasses import field
2
- from textwrap import dedent
3
-
4
- from pydantic.dataclasses import dataclass
5
-
6
-
7
- @dataclass
8
- class Docstring:
9
- body: str = ""
10
- param: dict[str, str] = field(default_factory=dict)
11
- type: dict[str, str] = field(default_factory=dict)
12
- returns: str = ""
13
- rtype: str = ""
14
-
15
-
16
- def parse_docstring(docstring: str) -> Docstring:
17
- """
18
- Parse a reStructuredText-style docstring.
19
- """
20
- # TODO: Support other standard docstring formats too.
21
- docstring = dedent(docstring).strip()
22
-
23
- lines = docstring.split("\n")
24
-
25
- result = Docstring()
26
- body_lines = []
27
-
28
- for line in lines:
29
- if line.strip().startswith(":"):
30
- break
31
- body_lines.append(line)
32
-
33
- result.body = "\n".join(body_lines).strip()
34
-
35
- parse_fields(lines[len(body_lines) :], result)
36
-
37
- return result
38
-
39
-
40
- def parse_fields(lines: list[str], result: Docstring):
41
- current_field = None
42
- current_content = []
43
-
44
- def save_current_field():
45
- if current_field and current_content:
46
- content = " ".join(current_content).strip()
47
- if current_field.startswith("param "):
48
- result.param[current_field[6:]] = content
49
- elif current_field.startswith("type "):
50
- result.type[current_field[5:]] = content
51
- elif current_field == "return":
52
- result.returns = content
53
- elif current_field == "rtype":
54
- result.rtype = content
55
-
56
- for line in lines:
57
- if line.strip().startswith(":"):
58
- save_current_field()
59
- current_field, _, content = line.strip()[1:].partition(":")
60
- current_content = [content.strip()]
61
- else:
62
- current_content.append(line.strip())
63
-
64
- save_current_field()
65
-
66
-
67
- ## Tests
68
-
69
-
70
- def test_parse_docstring():
71
- docstring1 = """
72
- Search for a string in files at the given paths and return their store paths.
73
- Useful to find all docs or resources matching a string or regex.
74
-
75
- :param sort: How to sort results. Can be `path` or `score`.
76
- :param ignore_case: Ignore case when searching.
77
- :type sort: str
78
- :type ignore_case: bool
79
- :return: The search results.
80
- :rtype: CommandOutput
81
- """
82
-
83
- parsed1 = parse_docstring(docstring1)
84
-
85
- print(f"Body: {parsed1.body}")
86
- print(f"Params: {parsed1.param}")
87
- print(f"Types: {parsed1.type}")
88
- print(f"Returns: {parsed1.returns}")
89
- print(f"Return type: {parsed1.rtype}")
90
-
91
- assert (
92
- parsed1.body
93
- == "Search for a string in files at the given paths and return their store paths.\nUseful to find all docs or resources matching a string or regex."
94
- )
95
- assert parsed1.param == {
96
- "sort": "How to sort results. Can be `path` or `score`.",
97
- "ignore_case": "Ignore case when searching.",
98
- }
99
- assert parsed1.type == {"sort": "str", "ignore_case": "bool"}
100
- assert parsed1.returns == "The search results."
101
- assert parsed1.rtype == "CommandOutput"
102
-
103
- docstring2 = """Some text."""
104
-
105
- parsed2 = parse_docstring(docstring2)
106
-
107
- assert parsed2.body == "Some text."
108
- assert parsed2.param == {}
109
- assert parsed2.type == {}
110
- assert parsed2.returns == ""
111
- assert parsed2.rtype == ""