Repository navigation
Conversation
…ed types (#14) scripts/gen_api_docs.py: - Signatures show the keyword-only '*' and positional-only '/', the literal value of a default constant, and @staticmethod, @classmethod or @Property. A long signature wraps one parameter per line. - Docstrings parse with returns_multiple_items=False, so a Returns section is one item. Sphinx roles, '::' literal blocks, RST links and '.. deprecated::' become Markdown, code fences and Starlight asides. Prose dashes become commas or parentheses, because the site uses no em-dash and the build turns '--' into one. - Attribute tables merge the class docstring's Attributes section, list the fields of private base classes, and hide pydantic internals. - Each facade class opens with a linked method index. - PAGES takes a member allowlist and can hide a module docstring. New sections: AnalysisLevel and the backend configs (core), the Java projections and enums, a results-and-errors page and a tree-sitter page. Module-level aliases such as TSType render as entries. - Two TreesitterSanitizer doctests that fail on cldk 2.0.0 are left out while the docstring holds them word for word (FAILING_EXAMPLES). scripts/requirements.txt pins griffe==2.3.2, so a regeneration with the deploy workflow gives the committed pages byte for byte.
Run the updated generator against the cldk 2.0.0 release. Only the blocks between the CLDK:API markers change on the existing pages. The new pages results.md and treesitter.md hold their generated block, and the sidebar lists them under Python SDK. This supersedes #8, which changed only the version strings.
Each page now gives an overview, a worked example on a pinned sample project and then the generated reference. Every sample ran on cldk==2.0.0, and every output comes from that run. - index.md: install, the three factories, the reference pages, the shared and the language-only methods, levels, the Python caveat. - core.md: factories, analysis levels, backends and Neo4j, the cache, errors, worked examples, the upgrade from 1.5.0. - python.md, java.md, typescript.md: setup per language (SYSTEM_PYTHON, the java extra with a JDK and Maven, npm), levels, names and keys, a worked example, a task table, the Neo4j backend and errors. - results.md, treesitter.md: how to read bounded results and taint results, the exceptions, and the tree-sitter helpers. Dead links to /cocoa/ and /guides/common-tasks/ are gone. An aside on each page lists the SDK docstring errors that break user code, until the SDK fixes them.
…tro (#14) Add starlight-links-validator 0.19.2. astro build now fails on a broken internal link or anchor in any page. The dead /cocoa/ and /guides/common-tasks/ links on the reference pages had survived because no check ran. The "Edit page" link pointed at the main branch, but astro is the default branch and the only branch that deploys.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14. Supersedes #8.
This PR rewrites the Python API reference (
/reference/python-api/) for cldk 2.0.0, and adds two pages: "Results and errors" and "Tree-sitter utilities". It also updates the generator that writes the reference from the SDK docstrings, and it adds a link check to the build.Merge order
Merge #15 first, then #16, then this PR, back to back.
v2.0.0-rc.8and installs griffe without the pin.astroalone, those pages still describe the release candidate.Commits
The four commits are easier to review one by one:
scripts/gen_api_docs.pyand the griffe pin. The generator changes are listed below.CLDK:APImarkers change, plus the two new pages and their sidebar entries.starlight-links-validatorand the edit link.Each commit builds.
The pages
Each language page has three parts: an overview, a worked example on a pinned sample project, and the generated reference.
index.mdSYSTEM_PYTHON), how the three factories fit together, the reference pages, the shared and the language-only methods, analysis levels, the Python value-flow caveatcore.mdpython.mdPythonAnalysison Flask: setup andSYSTEM_PYTHON, the four levels, names, the call graph, a worked example, a task table, Neo4j, errorsjava.mdJavaAnalysison Commons CLI: thejavaextra, the JDK and Maven, test sources, names (fully qualified parameter types), a worked example withtaint, what Java refuses, the cache, Neo4jtypescript.mdTypeScriptAnalysison Zod: what a run does to the project, levels, the cache trap, key formats, entrypoints, the Neo4j limit for declaration merging, errorsresults.md(new)treesitter.md(new)TreesitterJava,TreesitterPython,TreesitterSanitizer, and the move from the 1.xsource_codemodeEach page also has an "Errors in the generated reference" aside. It lists the SDK docstring errors that break user code, for example
page.has_more,sl.truncated,create(String), and the CRUD accessors. Remove each item when the SDK fixes the docstring.The generator
*and positional-only/. 57 public methods take keyword-only parameters, and the old signatures invited aTypeError. They also show default values as literals (page_size: int = 10000) and@staticmethodor@classmethod, and they wrap long lines.returns_multiple_items=False). Before, 103 of 124 split into one bullet per source line.::literal blocks, RST links and.. deprecated::become Markdown, Python code fences and Starlight asides. Prose dashes become commas or parentheses.TSTypeget entries.AnalysisLeveland the backend configs (core), the Java projections and enums, and the two new pages.TreesitterSanitizerdoctests that fail on cldk 2.0.0 are left out (FAILING_EXAMPLES) while the docstring holds them word for word.v2.0.0,scripts/requirements.txt) gives the committed pages.How the changes were checked
cldk==2.0.0from PyPI, on private copies of the pinned samples. The Neo4j samples ran on a private Neo4j instance.core.mdworked example myself. Every output matched: 75 classes, 652 nodes and 1980 edges on JDK 17, 31 main classes, 46 Flask classes, 53 Zod classes.astrowith ci(api-docs): build the reference from the latest stable SDK tag #15, docs: bring the guides, examples and install pages up to cldk 2.0.0 #16 and this PR merged, afternpm cifrom the committed lockfile, passes with 35 pages and 0 broken links.Open items
pull_requestbuild would catch it earlier.TypeScriptAnalysismethods have no docstring, so their rows in the method index have no summary.SDK problems found on the way
The docs work around these, and each one needs an SDK or analyzer fix:
CLDK.python()raisesRuntimeErrorin a run from a virtual environment. codeanalyzer-python readssys.base_executableinstead ofsys._base_executable. Present in 1.5.3 through 1.6.2. The pages give theSYSTEM_PYTHONworkaround.target_filesrun writes over it. The pages tell readers to passeager=True.taintandresolve_valueraiseSelectorNotInGraphbelow the needed level. They do this for a correct name, instead of giving the level message.unresolvedledger oftaintis always empty. No backend writesunresolved_dispatch.project_path.