Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ae47392
migrated src tracing here and add infra
juiwenchen Jun 11, 2025
f347c64
refactor name
juiwenchen Jun 11, 2025
482cba0
add ci and update ignore for mypy
juiwenchen Jun 11, 2025
3cbde6e
add action
juiwenchen Jun 11, 2025
7e7deb5
updated gitignore
juiwenchen Jun 11, 2025
384343d
add docs
juiwenchen Jun 12, 2025
1e600e4
remove leading spaces
juiwenchen Jun 12, 2025
177adfd
updated remote-url
juiwenchen Jun 12, 2025
c822c4f
adapted new repo
juiwenchen Jun 12, 2025
d55a864
fix bugs and improve config validation
juiwenchen Jun 16, 2025
d47566f
added configuration for src-trace
juiwenchen Jun 16, 2025
c2c2ba6
fixed mypy errors
juiwenchen Jun 16, 2025
d897edb
improve config validation
juiwenchen Jun 24, 2025
d5bc060
fixed mypy
juiwenchen Jun 25, 2025
edefdbe
improve config validation
juiwenchen Jun 25, 2025
4b0bf7a
disabled color for testing
juiwenchen Jun 25, 2025
97a2c19
strip ANSI
juiwenchen Jun 25, 2025
85e1592
set NO_COLOR
juiwenchen Jun 25, 2025
9a57ed3
removed first two lines
juiwenchen Jun 25, 2025
bdc569d
ignore format from typer
juiwenchen Jun 25, 2025
3fb60a2
improved docs
juiwenchen Jun 25, 2025
1988da7
updated pyproject
juiwenchen Jul 7, 2025
2b8dc69
added installation doc
juiwenchen Jul 7, 2025
b8e60ef
update docs
juiwenchen Jul 7, 2025
9d79598
add development docs
juiwenchen Jul 8, 2025
790050a
changed layout of docs
juiwenchen Jul 8, 2025
c3524aa
added CLI docs
juiwenchen Jul 8, 2025
57b1ac0
added typer ext
juiwenchen Jul 8, 2025
b5c0981
updated build cmd
juiwenchen Jul 8, 2025
1b8ff12
added contributing docs
juiwenchen Jul 8, 2025
33eedf8
update docs
juiwenchen Jul 8, 2025
f5a60b4
update oneline docs
juiwenchen Jul 9, 2025
fe6a476
updated docs
juiwenchen Jul 9, 2025
67c2ed7
added caution
juiwenchen Jul 9, 2025
a7600ab
enhance online docs
juiwenchen Jul 10, 2025
1eba831
added release action
juiwenchen Jul 10, 2025
ed0b2d0
test release action
juiwenchen Jul 10, 2025
1f99f62
test github_page
juiwenchen Jul 10, 2025
da93659
update release action
juiwenchen Jul 10, 2025
4eba349
use rye build
juiwenchen Jul 10, 2025
a916a49
remove test gh page
juiwenchen Jul 10, 2025
baaf83c
specified package location
juiwenchen Jul 10, 2025
95e1bdd
updated permission
juiwenchen Jul 10, 2025
2e7dd45
updated package-dir
juiwenchen Jul 10, 2025
a4ed9fb
updated
juiwenchen Jul 10, 2025
b304b51
updated
juiwenchen Jul 10, 2025
5ab9d39
updated
juiwenchen Jul 10, 2025
a3a5d7c
updated
juiwenchen Jul 10, 2025
54fa062
Reformatted docs
ubmarco Jul 10, 2025
c0af6b2
Rewrite some docs
ubmarco Jul 10, 2025
6521dbb
Wording
ubmarco Jul 10, 2025
8ffee7a
updated according to the review
juiwenchen Jul 10, 2025
a68da45
make CI happy
juiwenchen Jul 10, 2025
65663b5
confirm relative path
juiwenchen Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/actions/setup_rye/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Set up rye
runs:
using: 'composite'
steps:
# rye uses uv under the hood, so we need to set the cache directory correctly, based on the OS
- name: Set UV_CACHE_DIR for Linux
if: runner.os == 'Linux'
run: |
echo "UV_CACHE_DIR=/home/runner/.cache/uv" >> $GITHUB_ENV
shell: bash
- name: Set MATURIN_PEP517_ARGS for Linux
if: runner.os == 'Linux'
# make sure we always use zig, to get manylinux2014 compatible rust binaries
run: |
echo "MATURIN_PEP517_ARGS=--zig" >> $GITHUB_ENV
shell: bash
- name: Set UV_CACHE_DIR for MacOS
if: runner.os == 'macOS'
run: echo "UV_CACHE_DIR=/Users/gh-runner/Library/Caches/uv" >> $GITHUB_ENV
shell: bash
- name: Set UV_CACHE_DIR for Windows
if: runner.os == 'Windows'
run: echo "UV_CACHE_DIR=C:\\Users\\useblocks\\AppData\\Local\\uv-${{ runner.name }}" >> $env:GITHUB_ENV
shell: pwsh
# now install rye and sync the dependencies
- uses: eifinger/setup-rye@v4
with:
version: "0.42.0"
enable-cache: false
- run: rye sync
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: ci

on:
push:
branches: [main]
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:
types: [closed, labeled, reopened, unlabeled, synchronize, opened]

concurrency:
# For PRs, cancel in progress runs, if a new commit is pushed
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

jobs:
pre-commit:
name: Pre-commit
runs-on: [self-hosted, linux, x64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- run: python -m pip install pre-commit pre-commit-uv
# - uses: pre-commit/action@v3.0.1 # note we don't use this, since it calls ations/cache, which actually takes longer than without it
- run: pre-commit run --all --show-diff-on-failure --color=always

mypy:
name: MyPy
runs-on: [self-hosted, linux, x64]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_rye
- run: rye run mypy:all

pytest:
name: Pytest (${{ matrix.os }}-${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x64
- os: linux
arch: arm64
- os: windows
arch: x64
- os: macos
arch: arm64

runs-on: [self-hosted, "${{ matrix.os }}", "${{ matrix.arch }}"]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_rye
- run: rye test -a

docs:
name: Documentation build
runs-on: [self-hosted, linux, x64]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_rye
- name: Run documentation build
run: rye run docs

all_good:
# This job does nothing and is only used for the branch protection
# see https://github.com/marketplace/actions/alls-green#why

if: ${{ !cancelled() }}

needs:
- pre-commit
- mypy
- pytest
- docs

runs-on: [self-hosted, linux, x64]

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
53 changes: 53 additions & 0 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Workflow for building and deploying the Sphinx site to GitHub Pages
#
name: Deploy docs to GH Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Build
runs-on: [self-hosted, linux, x64]
steps:
- uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- uses: eifinger/setup-rye@v4
- run: rye sync
- name: Run documentation build
run: rye run docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: [self-hosted, linux, x64]
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release
on:
push:
tags:
- '[0-9].[0-9]+.[0-9]+'

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: read

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use flit instead to build, just check this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm can we change it in the next PR? all i know now is it works now and it's from papy

run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# python generated files
.ruff_cache
.pytest_cache
.mypy_cache
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
.venv

# lock files
requirements.lock
requirements-dev.lock

# Sphinx build output
**/_build

# rye is the primary tool, uv is only used for on-the-fly setups
uv.lock
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.2
hooks:
- id: ruff-format
name: python format
- id: ruff
alias: ruff-check
name: python lint
args: [--fix]

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format
# lint fetches schemas online at each call, deactivate for now
- id: taplo-lint
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.7
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
* [ ] Move code
* [ ] Create doc project, be based on ubCode/ubTrace
* [ ] ubCode ubproject.toml
* [ ] CI for docs and tests
* [ ] DNS for codelinks.useblocks.com
* [ ] Deployment on pypi (see Sphinx-Needs)
* [ ] Repo rules (no main pushes / branch protection)
* [ ] Cleanup ubTrace (files, ci, rye commands)
# Sphinx CodeLinks

A Sphinx extension for discovering, linking, and documenting source code across projects.

## Features

- **Source Discovery**: Automatically discover source files in your project
- **Virtual Documentation**: Generate documentation from code without modifying source files
- **Code Linking**: Create intelligent links between code elements
- **Sphinx Integration**: Seamless integration with existing Sphinx documentation

## Quick Start

```bash
pip install sphinx-codelinks
```

Add to your `conf.py`:

```python
extensions = ['sphinx_needs', 'sphinx_codelinks']
```

## Documentation

Full documentation: https://codelinks.useblocks.com

## Components

- **Source Discovery** ([`src/sphinx_codelinks/source_discovery`](src/sphinx_codelinks/source_discovery)): Code analysis and discovery
- **Virtual Docs** ([`src/sphinx_codelinks/virtual_docs`](src/sphinx_codelinks/virtual_docs)): Documentation generation
- **Sphinx Extension** ([`src/sphinx_codelinks/sphinx_extension`](src/sphinx_codelinks/sphinx_extension)): Sphinx integration
- **Command Line** ([`src/sphinx_codelinks/cmd.py`](src/sphinx_codelinks/cmd.py)): CLI interface

## Development

See [Development Guide](docs/source/development/) for contributing guidelines.
67 changes: 67 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

from datetime import datetime
from pathlib import Path
import tomllib

_project_data = tomllib.loads(
(Path(__file__).parent.parent / "pyproject.toml").read_text("utf8")
)["project"]

project = _project_data["name"]
author = _project_data["authors"][0]["name"]
copyright = f"{datetime.now().year}, {author}"
version = release = _project_data["version"]

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx_design",
"sphinx_needs",
"sphinx_codelinks",
"sphinx.ext.intersphinx",
"sphinx_code_tabs",
"sphinxcontrib.typer",
]

# exclude_patterns = []
templates_path = ["_templates"]
show_warning_types = True

todo_include_todos = True

# -- Options for intersphinx extension ---------------------------------------

intersphinx_mapping = {
"needs": ("https://sphinx-needs.readthedocs.io/en/latest/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_title = "CodeLinks"
html_theme = "furo"
# original source is in ubdocs repo at docs/developer_handbook/design/files/ubcode_favicon/favicon.ico
html_favicon = "source/_static/favicon.ico"
html_static_path = ["source/_static"]

html_theme_options = {
"sidebar_hide_name": True,
"top_of_page_buttons": ["view", "edit"],
"source_repository": "https://github.com/useblocks/sphinx-codelinks",
"source_branch": "main",
"source_directory": "docs/source/",
"light_logo": "sphinx-codelinks-logo_dark.svg",
"dark_logo": "sphinx-codelinks-logo_light.svg",
}
html_css_files = ["furo.css"]

src_trace_config_from_toml = "./src_trace.toml"
Binary file added docs/source/_static/favicon.ico
Binary file not shown.
Loading