A Jupyter/nbdev notebook decomposition core for context graphs: a notebook IS a CodeModule whose authored source is an ordered sequence of VERBATIM cells (the lossless source substrate), composing the python decomposer (code cells -> symbols) and the markdown decomposer (markdown cells -> prose) with interleaving edges. The first step toward graph-as-source-of-truth (notebook -> graph).
Project description
cjm-notebook-decompose-core
A Jupyter/nbdev notebook decomposition core for context graphs: a notebook IS a CodeModule whose authored source is an ordered sequence of VERBATIM cells (the lossless source substrate), composing the python decomposer (code cells -> symbols) and the markdown decomposer (markdown cells -> prose) with interleaving edges. The first step toward graph-as-source-of-truth (notebook -> graph).
Modules
cjm_notebook_decompose_core.__init__cjm_notebook_decompose_core.compose— Compose a parsed notebook onto dev-graph-schema nodes (the compositor).cjm_notebook_decompose_core.ingest— Flatten decomposed notebooks into graph elements (the queue-free half).cjm_notebook_decompose_core.project— Project a notebook BACK out of the graph (graph -> .ipynb) — the round-trip leg.cjm_notebook_decompose_core.read— Schema-free Jupyter/nbdev notebook parsing (stdlibjson).tests.test_compose— Compositor: read + compose a notebook onto CodeModule/Cell/CodeSymbol nodes + edges.tests.test_project— Round-trip: regenerate a notebook from its verbatim cells (graph/cells -> .ipynb).tests.test_reattribution— Cross-cell method re-attribution (@patch + incrementalClass.method = fnidioms).tests_manual.real_notebook— Dogfood the compositor on a REAL ecosystem nbdev notebook (against a scratch graph).
API
cjm_notebook_decompose_core.compose
DecomposedNotebookclass — A notebook bound to schema nodes: the module + verbatim cells + code symbols + edges.decompose_notebookfunction — Bind a parsed notebook onto a notebookCodeModule+ verbatim cells + symbols + edges.decompose_notebook_filefunction — Read + decompose a notebook file (module path fromdefault_exp/package, else the path).module_path_for_notebookfunction — Pick the notebook module path: the export target when known, else the.ipynbpath.
cjm_notebook_decompose_core.ingest
notebook_graph_elementsfunction — Collect decomposed notebooks into the node + edge wire-dict lists forextend_graph.
cjm_notebook_decompose_core.project
cells_for_modulefunction — Filter queried Cell nodes down to one notebook module (bymodule_idproperty).notebook_dict_from_cellsfunction — Rebuild the.ipynbJSON from verbatim cells (ordered by index).render_notebookfunction — Serialize regenerated cells to.ipynbJSON text.
cjm_notebook_decompose_core.read
ParsedCellclass — One notebook cell, parsed but not yet schema-bound.ParsedNotebookclass — The structural decomposition of one notebook.parse_directivesfunction — Extract nbdev#|directive bodies (the text after#|) from a cell.parse_notebookfunction — Parse a notebook's JSON into ordered cells + the#| default_exptarget.parse_notebook_filefunction — Read + parse a notebook file (UTF-8).
tests.test_compose
test_every_cell_is_verbatim_with_contains_and_nextfunctiontest_export_cells_yield_symbols_under_the_modulefunctiontest_ingest_flattens_and_is_idempotentfunctiontest_interleaving_markdown_documents_following_codefunctiontest_markdown_cell_prose_and_referencesfunctiontest_module_path_for_notebookfunctiontest_non_export_code_cells_harvest_call_namesfunction — A non-export code cell (nbdev's test/example vehicle) gets its bare call namestest_non_python_export_cell_keeps_verbatim_cellfunctiontest_notebook_is_a_codemodulefunctiontest_read_cells_directives_and_default_expfunctiontest_within_notebook_calls_resolvefunction
tests.test_project
test_cells_for_module_filters_by_modulefunctiontest_outputs_are_not_restored_but_source_is_exactfunctiontest_render_from_cellnodes_round_trips_sourcefunctiontest_render_from_graph_wire_dictsfunction
tests.test_reattribution
test_class_defines_the_reattributed_methodsfunctiontest_patch_and_assign_methods_reattributed_to_classfunctiontest_reattributed_method_keeps_cell_keyfunctiontest_reattribution_preserves_verbatim_round_tripfunctiontest_unrecognized_method_shaped_is_surfaced_not_reattributedfunction
tests_manual.real_notebook
mainfunction
Dependencies
Depends on: cjm-context-graph-projection, cjm-dev-graph-schema, cjm-markdown-decompose-core, cjm-python-decompose-core
Used by: cjm-context-graph-projection
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cjm_notebook_decompose_core-0.0.4.tar.gz.
File metadata
- Download URL: cjm_notebook_decompose_core-0.0.4.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
478c3067e081edcc957374eaf0430731d81bcb7ee9eb45d365fc4d5e248231ec
|
|
| MD5 |
64cf5af7d37c9113eebe13d9a93caf72
|
|
| BLAKE2b-256 |
667e9c0fb2087745591e041077c9723e9c03990b35752bb3b583f9c174ae78d8
|
File details
Details for the file cjm_notebook_decompose_core-0.0.4-py3-none-any.whl.
File metadata
- Download URL: cjm_notebook_decompose_core-0.0.4-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23473481af5c757b1d6101558b283506c6491de437e4334ab277eafb335c8ee9
|
|
| MD5 |
1a6a38b44b3adeed038b12bf611d0cb6
|
|
| BLAKE2b-256 |
895290176880a73fbe8664af61237bbe6019391bc6183afe381d30e67e2f4cce
|