> built 2026-11-24 01:33 UTC from a238f15 (main) · jy 0.1.23. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# jy

Tools to control JS from Python.

(`jy` stands for “Js pY” or “Js python proxY”.)

To install:	`pip install jy`

[Documentation](https://i2mint.github.io/jy/)

# Example

Say you have the `test01.js`
(whose contents are displayed in the next subsection).

```none
from jy import add_js_funcs
js = add_js_funcs("./test01.js")
```

js has two methods called bar and foo

```none
assert sorted([x for x in dir(js) if not x.startswith('_')]) == [
    'add_one', 'bar', 'foo', 'obj', 'prop', 'with_arrow_func', 'with_let'
]
```

They mirror the signatures of the underlying JS functions

```none
from inspect import signature
assert str(signature(js.foo)) == "(a, b='hello', c=3)"
assert str(signature(js.bar)) == "(green, eggs='food', and=True, /, ham=4)"
```

(`and` is a Python keyword, so it – and every parameter before it – is
exposed as positional-only, hence the `/`. You can never pass `and=...` by
keyword from Python anyway.)

Calling this function returns a string
(the code to call the underlying JS function)

```none
assert js.foo(1, 'hi', 5) == 'foo(1, "hi", 5)'
```

Notice that you can use positional or keyword arguments
Also, notice that though “prop” is the name of `js`’s attribute,
the function call string does indeed use the original full reference:
`func.assigned.to.nested.prop`

```none
assert js.prop('up') == (
    'func.assigned.to.nested.prop("up")'
)
```

Notice that the python (signature) defaults are applied before translating to JS

```none
assert js.bar(42) == 'bar(42, "food", true, 4)'
alt_js = add_js_funcs("./test01.js", apply_defaults=False)
```

You can opt not to do this by specifying `apply_defaults=False`
This will result in only injecting those inputs you specify in the js call string,
which will have the effect of letting JS apply its defaults, what ever they are

```none
alt_js = add_js_funcs("./test01.js", apply_defaults=False)
assert alt_js.bar(42) == 'bar(42)'
```

# Appendix

## The `test01.js` file’s contents

```javascript
// "test01.js" file
// Straight function definition
function foo(a, b="hello", c= 3) {
    return a + b.length * c
}

// Straight function definition
function bar(green, eggs = 'food', and= true, ham= 4) {
    if (and) return eggs.length * ham
}

// global callable variable
add_one = function (x) {
    return x + 1
}

// does the presence of a let break the parser?
let with_let = function (x) {
    return x + 2
}

// with arrow func
// (also testing if const breaks the parse)
const with_arrow_func = (y, z= 1) => y * z

// function assigned to a nested property
func.assigned.to.nested.prop = function (x) {
    return x + 3
}

// function nested in some other function, assigned to a variable
var obj = (function (exports) {
    function bar(name) {
        return name + "__"
    }
})

```

<p class="epythet-aggregates">This documentation as a single file: <a href="jy.md">jy.md</a> (Markdown, for agents).</p>


# _autosummary/jy.bridge.html.md

# jy.bridge

Python portals to JS

### Functions

| [`add_js_funcs`](_autosummary/jy.bridge.html.md#jy.bridge.add_js_funcs)(js_code, \*[, obj, name, ...])   | Add js call functions as attributes to an object.   |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| `mk_py_binder_func`(name, params, \*[, prefix, ...])                                           |                                                     |

### Classes

| [`JsBridge`](_autosummary/jy.bridge.html.md#jy.bridge.JsBridge)()   | The default class to make instances that will contain methods that mirror JS function calls   |
|---------------------------------------------------------------|-----------------------------------------------------------------------------------------------|

### *class* jy.bridge.JsBridge

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The default class to make instances that will contain methods that mirror JS
function calls

### jy.bridge.add_js_funcs(js_code, \*, obj=None, name=None, encoding=None, forbidden_method_names=(), apply_defaults=True, value_trans=<function dflt_py_to_js_value_trans>, runtime=None)

Add js call functions as attributes to an object.

If object is not given, `add_js_funcs` will use a new `JsBridge` instance.

```pycon
>>> js_code = """
... function foo(a, b="hello", c= 3) {
...     return a + b.length * c
... }
... const bar = (y, z = 1) => y * z
... func.assigned.to.nested.prop = function (x) {
...     return x + 3
... }
... """
>>> js = add_js_funcs(js_code)
>>> from inspect import signature
>>> list(vars(js))
['foo', 'bar', 'prop']
>>> signature(js.foo)
<Sig (a, b='hello', c=3)>
>>> js.foo(1, 'hi')
'foo(1, "hi", 3)'
>>> js.prop('up')
'func.assigned.to.nested.prop("up")'
```

With a `runtime` (a callable taking the call text and returning its value,
e.g. [`jy.runtime.NodeRuntime`](_autosummary/jy.runtime.html.md#jy.runtime.NodeRuntime)), the functions execute the call instead
of returning its text.

### jy.bridge.iskeyword()

x._\_contains_\_(y) <==> y in x.


# _autosummary/jy.html.md

# jy

Python functions to talk to Javascript

### Modules

| [`bridge`](_autosummary/jy.bridge.html.md#module-jy.bridge)     | Python portals to JS                                                       |
|------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [`js_parse`](_autosummary/jy.js_parse.html.md#module-jy.js_parse) | Utils to parse JS                                                          |
| [`runtime`](_autosummary/jy.runtime.html.md#module-jy.runtime)   | Runtimes that execute the call strings jy builds, and return their values. |
| [`test`](_autosummary/jy.test.html.md#module-jy.test)         |                                                                            |
| [`ts_parse`](_autosummary/jy.ts_parse.html.md#module-jy.ts_parse) | Tools to parse TS code                                                     |
| [`util`](_autosummary/jy.util.html.md#module-jy.util)         | General utils                                                              |


# _autosummary/jy.js_parse.html.md

# jy.js_parse

Utils to parse JS

### Functions

| [`append_to_func_body`](_autosummary/jy.js_parse.html.md#jy.js_parse.append_to_func_body)(func_def_code, ...)          | Append code to the body of a function definition                                    |
|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [`dflt_py_to_js_value_trans`](_autosummary/jy.js_parse.html.md#jy.js_parse.dflt_py_to_js_value_trans)(x)                     | Python value -> JS literal text, via `json.dumps` (quotes and nesting are escaped). |
| [`extract_func_name_and_params`](_autosummary/jy.js_parse.html.md#jy.js_parse.extract_func_name_and_params)(ast_node)           | Extract one or several function `(name, params)` pair(s) from an AST node           |
| [`extract_function_def_parts`](_autosummary/jy.js_parse.html.md#jy.js_parse.extract_function_def_parts)(func_def_code)        | Extract the body of a function definition from its code                             |
| `extract_js_func_params`(params_list)                                                             |                                                                                     |
| [`func_name_and_params_pairs`](_autosummary/jy.js_parse.html.md#jy.js_parse.func_name_and_params_pairs)(js_code, \*[, ...])   | Get `(name, params)` pairs of function definitions extracted from `js_code`.        |
| `if_none_output_raise_unknown_type`([context])                                                    |                                                                                     |
| [`parse_js`](_autosummary/jy.js_parse.html.md#jy.js_parse.parse_js)(js_code[, encoding, ingress, egress])   | Parse JavaScript source (or a path to a `.js` file) into an esprima AST.            |
| [`parse_js_code`](_autosummary/jy.js_parse.html.md#jy.js_parse.parse_js_code)(js_code[, encoding, ingress, ...]) | Parse JavaScript source (or a path to a `.js` file) into an esprima AST.            |
| [`replace_ids_in_code`](_autosummary/jy.js_parse.html.md#jy.js_parse.replace_ids_in_code)(code[, patterns])            | Replaces IDs in a mixed HTML, CSS, and JS string with unique versions.              |
| [`variable_declarations_pairs`](_autosummary/jy.js_parse.html.md#jy.js_parse.variable_declarations_pairs)(src, \*[, encoding]) | Yield `(name, value)` pairs for the top-level variable declarations in JS.          |

### Exceptions

| [`UnknownNodeType`](_autosummary/jy.js_parse.html.md#jy.js_parse.UnknownNodeType)(node_type[, context])   | To be raised when an AST node type wasn't handled by a function   |
|------------------------------------------------------------------------------------------|-------------------------------------------------------------------|

### *exception* jy.js_parse.UnknownNodeType(node_type, context='')

Bases: [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

To be raised when an AST node type wasn’t handled by a function

### jy.js_parse.append_to_func_body(func_def_code, code_to_append)

Append code to the body of a function definition

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### jy.js_parse.dflt_py_to_js_value_trans(x)

Python value -> JS literal text, via `json.dumps` (quotes and nesting are escaped).

```pycon
>>> dflt_py_to_js_value_trans(True), dflt_py_to_js_value_trans(None)
('true', 'null')
>>> dflt_py_to_js_value_trans('say "hi"\n')
'"say \\"hi\\"\\n"'
>>> dflt_py_to_js_value_trans([{"a": 1}, {"b": [2, "x"]}])
'[{"a": 1}, {"b": [2, "x"]}]'
```

Values `json` cannot encode are passed through unchanged (so a caller can
supply a raw JS expression object whose `str` is the code).

### jy.js_parse.extract_func_name_and_params(ast_node)

Extract one or several function `(name, params)` pair(s) from an AST node

### jy.js_parse.extract_function_def_parts(func_def_code)

Extract the body of a function definition from its code

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### jy.js_parse.func_name_and_params_pairs(js_code, , encoding=None)

Get `(name, params)` pairs of function definitions extracted from `js_code`.

```pycon
>>> js_code = '''
... function foo(a, b="hello", c= 3) {
...     return a + b.length * c
... }
... const bar = (y, z = 1) => y * z
... func.assigned.to.nested.prop = function (x) {
...     return x + 3
... }'''
>>> assert list(func_name_and_params_pairs(js_code)) == [
...     ('foo', [
...         {'name': 'a'},
...         {'name': 'b', 'default': 'hello'},
...         {'name': 'c', 'default': 3}
...     ]),
...     ('bar', [
...         {'name': 'y'},
...         {'name': 'z', 'default': 1}
...     ]),
...     ('func.assigned.to.nested.prop', [
...         {'name': 'x'}
...     ])
... ]
```

### jy.js_parse.parse_js(js_code, encoding=None, \*, ingress=<function <lambda>>, egress=<function <lambda>>)

Parse JavaScript source (or a path to a `.js` file) into an esprima AST.

`js_code` may be a string of JS or a filesystem path, in which case the
file is read (honoring `encoding`). `ingress` preprocesses the source
before parsing; `egress` post-processes the resulting AST.

```pycon
>>> tree = parse_js("const x = 42;")
>>> tree.body[0].type
'VariableDeclaration'
>>> tree.body[0].declarations[0].id.name
'x'
```

* **Return type:**
  `Script`

### jy.js_parse.parse_js_code(js_code, encoding=None, \*, ingress=<function <lambda>>, egress=<function <lambda>>)

Parse JavaScript source (or a path to a `.js` file) into an esprima AST.

`js_code` may be a string of JS or a filesystem path, in which case the
file is read (honoring `encoding`). `ingress` preprocesses the source
before parsing; `egress` post-processes the resulting AST.

```pycon
>>> tree = parse_js("const x = 42;")
>>> tree.body[0].type
'VariableDeclaration'
>>> tree.body[0].declarations[0].id.name
'x'
```

* **Return type:**
  `Script`

### jy.js_parse.replace_ids_in_code(code, patterns=('id="([^"]+)"', '#([a-zA-Z][\\\\w\\\\-]\*)', 'document\\\\.getElementById\\\\("([^"]+)"\\\\)'))

Replaces IDs in a mixed HTML, CSS, and JS string with unique versions.

### Args

- code (str): The input code containing HTML, CSS, and/or JS.
- patterns (tuple): A tuple of regex patterns to match IDs.

### Returns

- tuple: A tuple containing the modified code and a dictionary of old-to-new ID mappings.

This function is useful to make id-unique copies of HTML/JS components that have IDs.
This need was noticed and discussed in: [https://github.com/i2mint/jy/discussions/3#discussioncomment-6862843](https://github.com/i2mint/jy/discussions/3#discussioncomment-6862843)

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

### jy.js_parse.variable_declarations_pairs(src, , encoding=None)

Yield `(name, value)` pairs for the top-level variable declarations in JS.

Literal, object, array and unary-minus initializers are evaluated to their
Python equivalents; other initializer kinds yield `None`. A leading
`export` on a declaration is stripped first, so ES-module sources parse.

```pycon
>>> list(variable_declarations_pairs("const a = 3; let b = 'hi';"))
[('a', 3), ('b', 'hi')]
>>> list(variable_declarations_pairs("export const config = {x: 1, y: [2, 3]};"))
[('config', {'x': 1, 'y': [2, 3]})]
>>> list(variable_declarations_pairs("var n = -5; const flag = true;"))
[('n', -5), ('flag', True)]
```


# _autosummary/jy.runtime.html.md

# jy.runtime

Runtimes that execute the call strings jy builds, and return their values.

A runtime is any callable `(call_text: str) -> value`. [`NodeRuntime`](_autosummary/jy.runtime.html.md#jy.runtime.NodeRuntime)
runs the call in a fresh `node` process loaded with the JS source, and decodes
the JSON-serialized result (`Promise` results are awaited).
[`PlaywrightRuntime`](_autosummary/jy.runtime.html.md#jy.runtime.PlaywrightRuntime) does the same in a browser page.

```pycon
>>> from jy import add_js_funcs
>>> from jy.runtime import NodeRuntime
>>> code = "function shout(s, n=1) { return s.toUpperCase() + '!'.repeat(n) }"
>>> js = add_js_funcs(code, runtime=NodeRuntime(code))
>>> js.shout('say "hi"', 2)
'SAY "HI"!!'
```

### Module Attributes

| [`RESULT_MARKER`](_autosummary/jy.runtime.html.md#jy.runtime.RESULT_MARKER)   | Line prefix marking the JSON result among whatever else the JS prints.   |
|------------------------------------------------------------------|--------------------------------------------------------------------------|

### Classes

| [`NodeRuntime`](_autosummary/jy.runtime.html.md#jy.runtime.NodeRuntime)([js_code, prelude, node, timeout])   | Execute jy call strings in `node` (one process per call, stateless).       |
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [`PlaywrightRuntime`](_autosummary/jy.runtime.html.md#jy.runtime.PlaywrightRuntime)([js_code, url, browser, ...])  | Execute jy call strings in a browser page (Playwright), one page per call. |

### Exceptions

| [`JsRuntimeError`](_autosummary/jy.runtime.html.md#jy.runtime.JsRuntimeError)   | The JS call failed (non-zero exit); the message carries stderr.   |
|-------------------------------------------------------------------|-------------------------------------------------------------------|

### *exception* jy.runtime.JsRuntimeError

Bases: [`RuntimeError`](https://docs.python.org/3/builtins/exceptions.html#RuntimeError)

The JS call failed (non-zero exit); the message carries stderr.

### *class* jy.runtime.NodeRuntime(js_code='', , prelude='', node='node', timeout=60)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Execute jy call strings in `node` (one process per call, stateless).

`js_code` is evaluated before each call (`prelude` is extra code run
first, e.g. a `require`). `node` is the executable (or an argv prefix),
`timeout` bounds one call in seconds.

#### script(call_text)

The full program run for one call.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* jy.runtime.PlaywrightRuntime(js_code='', , url=None, browser='chromium', headless=True, timeout=60)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Execute jy call strings in a browser page (Playwright), one page per call.

`js_code` is injected into a blank page (or the page at `url`) as a script,
then the call runs in the page, so DOM and browser APIs are available. Results
are JSON-serialized by Playwright; `Promise` results are awaited.

Needs the optional `browser` extra of jy (it installs `playwright`; then run
`playwright install chromium`). It is imported only when a call is made.

```pycon
>>> from jy import add_js_funcs
>>> from jy.runtime import PlaywrightRuntime
>>> code = "function title(s) { return document.title + s }"
>>> js = add_js_funcs(code, runtime=PlaywrightRuntime(code))
>>> js.title("!")
'!'
```

### jy.runtime.RESULT_MARKER *= '\\x00jy-result\\x00'*

Line prefix marking the JSON result among whatever else the JS prints.


# _autosummary/jy.test.html.md

# jy.test

### Modules

| [`test_bridge`](_autosummary/jy.test.test_bridge.html.md#module-jy.test.test_bridge)     | Tests for the bridge module   |
|---------------------------------------------------------------------------------------------|-------------------------------|
| [`test_js_parse`](_autosummary/jy.test.test_js_parse.html.md#module-jy.test.test_js_parse) | Tests for js_bridge           |


# _autosummary/jy.test.test_bridge.html.md

# jy.test.test_bridge

Tests for the bridge module

### Functions

| [`test_add_js_call_attributes_to_obj`](_autosummary/jy.test.test_bridge.html.md#jy.test.test_bridge.test_add_js_call_attributes_to_obj)()   | See test_js_parse.test_func_name_and_params_pairs for intermediate data of this test   |
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|

### jy.test.test_bridge.test_add_js_call_attributes_to_obj()

See test_js_parse.test_func_name_and_params_pairs for intermediate data of this test


# _autosummary/jy.test.test_js_parse.html.md

# jy.test.test_js_parse

Tests for js_bridge

### Functions

| `test_func_name_and_params_pairs`()   |    |
|---------------------------------------|----|
| `test_replace_ids_in_code`()          |    |


# _autosummary/jy.ts_parse.html.md

# jy.ts_parse

Tools to parse TS code

### Functions

| [`default_handler`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.default_handler)(code, node)                       | Default handler for nodes that don't have a specific handler.                          |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [`extract_parameters`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.extract_parameters)(code, parameters_node)         | Generator function that yields parameter dictionaries.                                 |
| [`find_function_type_node`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.find_function_type_node)(node)                     | Recursively search for a 'function_type' node within a given node.                     |
| [`handle_interface_declaration`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.handle_interface_declaration)(code, node)          | Handle 'interface_declaration' nodes by traversing their members.                      |
| [`handle_method_signature`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.handle_method_signature)(code, node)               | Handle 'method_signature' nodes, yielding (method name, method info) tuples.           |
| [`handle_property_signature`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.handle_property_signature)(code, node)             | Handle 'property_signature' nodes, yielding (property name, property info) tuples.     |
| [`parse_ts`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.parse_ts)(code[, node])                            | Generator function that traverses the syntax tree and yields (name, info dict) tuples. |
| [`parse_ts_with_oa`](_autosummary/jy.ts_parse.html.md#jy.ts_parse.parse_ts_with_oa)(ts_code, \*[, schema_name, ...]) | Parse TypeScript code using the OpenAI API.                                            |
| `test_parse_ts`()                                                                                  |                                                                                        |

### jy.ts_parse.default_handler(code, node)

Default handler for nodes that don’t have a specific handler.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]]

### jy.ts_parse.extract_parameters(code, parameters_node)

Generator function that yields parameter dictionaries.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

### jy.ts_parse.find_function_type_node(node)

Recursively search for a ‘function_type’ node within a given node.

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any) | [`None`](https://docs.python.org/3/builtins/constants.html#None)

### jy.ts_parse.handle_interface_declaration(code, node)

Handle ‘interface_declaration’ nodes by traversing their members.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]]

### jy.ts_parse.handle_method_signature(code, node)

Handle ‘method_signature’ nodes, yielding (method name, method info) tuples.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]]

### jy.ts_parse.handle_property_signature(code, node)

Handle ‘property_signature’ nodes, yielding (property name, property info) tuples.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]]

### jy.ts_parse.parse_ts(code, node=None)

Generator function that traverses the syntax tree and yields (name, info dict) tuples.

If ‘node’ is None, it parses the code and starts traversal from the root node.

### Example

```pycon
>>> code = '''
... interface Example {
...     prop1: string;
...     func1(a: number): void;
... }
... '''
>>> items = list(parse_ts(code))
>>> for name, info in items:
...     print(f"Name: {name}, Kind: {info['kind']}")
Name: prop1, Kind: property
Name: func1, Kind: function
```

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]]

### jy.ts_parse.parse_ts_with_oa(ts_code, , schema_name='parsed_ts', strict=False, model='gpt-4o', extra_context='')

Parse TypeScript code using the OpenAI API.


# _autosummary/jy.util.html.md

# jy.util

General utils

### Functions

| [`js_files_as_attrs`](_autosummary/jy.util.html.md#jy.util.js_files_as_attrs)(rootdir)   | Will make a JsFiles, but where the keys are available as attributes.   |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------|

### Classes

| [`JsFiles`](_autosummary/jy.util.html.md#jy.util.JsFiles)(\*args[, delete_func, ...])   | A store of js files   |
|----------------------------------------------------------------------------------------|-----------------------|
| [`mk_js_files`](_autosummary/jy.util.html.md#jy.util.mk_js_files)                           |                       |

### *class* jy.util.JsFiles(\*args, delete_func=None, write_open_kwargs=None, write_func=None, \*\*kwargs)

Bases: `Store`

A store of js files

#### is_valid_key(k, \*args, \_\_name='is_valid_key', \*\*kwargs)

`is_valid_key` on the inner key – see `mk_relative_path_store`.

#### validate_key(k, \*args, \_\_name='validate_key', \*\*kwargs)

`validate_key` on the inner key – see `mk_relative_path_store`.

### jy.util.js_files_as_attrs(rootdir)

Will make a JsFiles, but where the keys are available as attributes.
To do so, any non alphanumerics of file name are replaced with underscore,
and there can be no two files that collide with that key transformation!

### jy.util.mk_js_files

alias of [`JsFiles`](_autosummary/jy.util.html.md#jy.util.JsFiles)


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-24 01:33 UTC** from commit <a href="https://github.com/i2mint/jy/commit/a238f1512bef214a99e1ee1b4aae5cdf3c25f4cf"><code>a238f15</code></a> on branch <code>main</code>, for **jy 0.1.23** (from <code>pyproject.toml</code>).

#### NOTE
Nothing suggests a mismatch: the tree was clean at the commit above, and the documented version is the one on PyPI.

## Source

|                     |                                                                                                                                                  |
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/i2mint/jy/commit/a238f1512bef214a99e1ee1b4aae5cdf3c25f4cf"><code>a238f1512bef214a99e1ee1b4aae5cdf3c25f4cf</code></a> |
| Branch              | <code>main</code>                                                                                                                                |
| Tags at this commit | none                                                                                                                                             |
| Working tree        | clean                                                                                                                                            |
| Remote              | <code>https://github.com/i2mint/jy</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>i2mint/jy</code>                                                                     |
| Run          | <a href="https://github.com/i2mint/jy/actions/runs/45305659893">45305659893</a>            |
| Ref          | <code>refs/heads/main</code>                                                               |
| Event commit | <code>a238f1512bef214a99e1ee1b4aae5cdf3c25f4cf</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.25  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                   |
|---------------|-------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>pydata_sphinx_theme</code>) |
| accent        | <code>#536000</code>                                              |
| api_generator | <code>autosummary</code>                                          |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code>  |
| agent_outputs | <code>true</code>                                                 |
| aggregates    | <code>md</code>                                                   |
| ai_artifacts  | <code>true</code>                                                 |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/jy/0.1.23/">0.1.23</a>, the same as the documented version.

## Reproduce

```bash
git clone https://github.com/i2mint/jy && cd jy
git checkout a238f1512bef214a99e1ee1b4aae5cdf3c25f4cf
pip install "epythet==0.2.25"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# api.html.md

# API reference

| [`jy`](_autosummary/jy.html.md#module-jy)   | Python functions to talk to Javascript   |
|-----------------------------------------------------------------|------------------------------------------|


