CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-nbdev

Create delightful software with Jupyter Notebooks

Pending
Overview
Eval results
Files

configuration.mddocs/

Project Configuration

Project setup, configuration management, and bootstrapping functionality for new nbdev projects. The configuration system uses settings.ini files to manage project settings and supports both project-level and global configuration.

Capabilities

Project Creation

Create and initialize configuration for new nbdev projects with sensible defaults.

def nbdev_create_config(
    repo: str = None,
    branch: str = None,
    user: str = None,
    author: str = None,
    author_email: str = None,
    description: str = None,
    path: str = '.',
    cfg_name: str = 'settings.ini',
    **kwargs
):
    """
    Create configuration for new nbdev project.
    
    Creates a settings.ini file with default values for lib_name, version,
    description, and other project settings. Prompts user for required information
    and attempts to infer settings from git repository.
    """

Usage Example:

from nbdev.config import nbdev_create_config

# Create new project configuration
nbdev_create_config()
# This will create settings.ini with project defaults

Configuration Access

Access and query current project configuration settings.

def get_config():
    """
    Get current configuration settings.
    
    Returns:
        Config object with all project settings loaded from settings.ini
        
    Raises:
        FileNotFoundError: If no settings.ini found in current directory or parents
    """

def config_key(key: str):
    """
    Get specific configuration value by key.
    
    Args:
        key: Configuration key to retrieve
        
    Returns:
        Configuration value for the specified key
    """

def is_nbdev() -> bool:
    """
    Check if current directory is an nbdev project.
    
    Returns:
        True if settings.ini exists and contains nbdev configuration
    """

Usage Examples:

from nbdev.config import get_config, config_key, is_nbdev

# Check if current directory is nbdev project
if is_nbdev():
    # Get full configuration
    config = get_config()
    print(f"Library: {config.lib_name}")
    print(f"Version: {config.version}")
    print(f"Description: {config.description}")
    
    # Get specific configuration values
    lib_path = config_key('lib_path')
    doc_path = config_key('doc_path')

Project Structure

Create output directories and project structure based on configuration.

def create_output():
    """
    Create output directories based on configuration.
    
    Creates lib_path and doc_path directories if they don't exist,
    based on current project configuration settings.
    """

def add_init():
    """
    Add __init__.py files to package directories.
    
    Ensures proper Python package structure by adding __init__.py files
    to all subdirectories in the library path.
    """

Version Management

Update and manage project version information across multiple files.

def update_version(version: str):
    """
    Update package version across project files.
    
    Args:
        version: New version string (e.g., "1.2.3")
        
    Updates version in:
    - settings.ini
    - __init__.py (if put_version_in_init is True)
    - pyproject.toml (if update_pyproject is True)
    """

def update_proj():
    """
    Update project configuration and dependencies.
    
    Updates pyproject.toml with current settings and ensures
    project metadata is consistent across configuration files.
    """

Source Code Display

Display source code of objects for debugging and exploration.

def show_src(obj):
    """
    Show source code of an object.
    
    Args:
        obj: Python object to display source for
        
    Returns:
        Formatted source code display
    """

File Operations

Write notebook cells to files with proper formatting and structure.

def write_cells(cells, path):
    """
    Write notebook cells to a file.
    
    Args:
        cells: List of notebook cells to write
        path: Output file path
        
    Writes cells to the specified path with proper Python formatting,
    imports, and structure.
    """

Configuration Templates

pyproj_tmpl: str

Template string for generating pyproject.toml files with correct project structure and dependencies.

Configuration Keys

Common configuration keys available through config_key():

  • lib_name: Package name
  • lib_path: Path to package source code
  • version: Package version
  • description: Package description
  • author: Package author
  • author_email: Author email address
  • copyright: Copyright notice
  • license: License type
  • git_url: Git repository URL
  • doc_host: Documentation host URL
  • doc_baseurl: Documentation base URL
  • doc_path: Documentation output path
  • nbs_path: Notebooks source path
  • tst_flags: Test execution flags
  • custom_sidebar: Use custom sidebar
  • black_formatting: Enable black code formatting
  • clean_ids: Remove notebook cell IDs
  • jupyter_hooks: Enable Jupyter git hooks

Usage Example:

from nbdev.config import get_config

config = get_config()

# Access common settings
print(f"Package: {config.lib_name}")
print(f"Source: {config.lib_path}")  
print(f"Docs: {config.doc_path}")
print(f"Notebooks: {config.nbs_path}")
print(f"Version: {config.version}")
print(f"Git URL: {config.git_url}")

Install with Tessl CLI

npx tessl i tessl/pypi-nbdev

docs

cleaning.md

configuration.md

development-tools.md

documentation.md

export.md

git-integration.md

index.md

release-management.md

synchronization.md

testing.md

tile.json