cleanup code
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
"""Model package for doc-forge documentation objects."""
|
||||
|
||||
from .project import Project
|
||||
from .module import Module
|
||||
from .object import DocObject
|
||||
from .nav import Navigation, NavEntry
|
||||
|
||||
__all__ = [
|
||||
"Project",
|
||||
"Module",
|
||||
"DocObject",
|
||||
"Navigation",
|
||||
"NavEntry",
|
||||
]
|
||||
@@ -1,72 +0,0 @@
|
||||
"""Type stubs for doc-forge model package."""
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from pathlib import Path
|
||||
|
||||
class DocObject:
|
||||
"""Represents a Python documentation object (class, function, variable, etc.)."""
|
||||
|
||||
name: str
|
||||
kind: str
|
||||
path: str
|
||||
signature: Optional[str]
|
||||
docstring: Optional[str]
|
||||
members: Dict[str, 'DocObject']
|
||||
|
||||
def __init__(self, name: str, kind: str, path: str, signature: Optional[str] = None, docstring: Optional[str] = None) -> None: ...
|
||||
|
||||
def add_member(self, member: 'DocObject') -> None: ...
|
||||
|
||||
def get_member(self, name: str) -> Optional['DocObject']: ...
|
||||
|
||||
def is_private(self) -> bool: ...
|
||||
|
||||
class Module:
|
||||
"""Represents a Python module in the documentation model."""
|
||||
|
||||
path: str
|
||||
docstring: Optional[str]
|
||||
members: Dict[str, DocObject]
|
||||
|
||||
def __init__(self, path: str, docstring: Optional[str] = None) -> None: ...
|
||||
|
||||
def add_object(self, obj: DocObject) -> None: ...
|
||||
|
||||
def get_object(self, name: str) -> Optional[DocObject]: ...
|
||||
|
||||
def get_public_objects(self) -> List[DocObject]: ...
|
||||
|
||||
class Project:
|
||||
"""Root container for all documentation in a project."""
|
||||
|
||||
name: str
|
||||
version: Optional[str]
|
||||
modules: Dict[str, Module]
|
||||
nav: 'Navigation'
|
||||
|
||||
def __init__(self, name: str, version: Optional[str] = None) -> None: ...
|
||||
|
||||
def add_module(self, module: Module) -> None: ...
|
||||
|
||||
def get_module(self, path: str) -> Optional[Module]: ...
|
||||
|
||||
def get_all_modules(self) -> List[Module]: ...
|
||||
|
||||
class Navigation:
|
||||
"""Navigation structure derived from project modules."""
|
||||
|
||||
entries: List['NavEntry']
|
||||
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
def add_entry(self, entry: 'NavEntry') -> None: ...
|
||||
|
||||
def get_entry(self, title: str) -> Optional['NavEntry']: ...
|
||||
|
||||
class NavEntry:
|
||||
"""Single navigation entry linking to a module."""
|
||||
|
||||
title: str
|
||||
module: str
|
||||
|
||||
def __init__(self, title: str, module: str) -> None: ...
|
||||
@@ -1,129 +0,0 @@
|
||||
"""Module representation in the doc-forge documentation model.
|
||||
|
||||
Module represents a Python module that can be documented. It serves as
|
||||
a container for all the documentation objects within that module,
|
||||
including classes, functions, attributes, and constants.
|
||||
|
||||
Each Module corresponds to a Python import path and contains the
|
||||
module-level docstring along with all documented members.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from .object import DocObject
|
||||
|
||||
|
||||
class Module:
|
||||
"""Represents a Python module in the documentation model.
|
||||
|
||||
A Module is the primary organizational unit in doc-forge. It corresponds
|
||||
to a Python module (identified by its import path) and contains all
|
||||
the documentation objects within that module.
|
||||
|
||||
Attributes:
|
||||
path: The import path of the module (e.g., "package.submodule")
|
||||
docstring: Optional module-level docstring
|
||||
members: Dictionary of all documented objects in the module
|
||||
"""
|
||||
|
||||
def __init__(self, path: str, docstring: Optional[str] = None) -> None:
|
||||
"""Initialize a Module.
|
||||
|
||||
Args:
|
||||
path: The import path of the module
|
||||
docstring: Optional module-level docstring
|
||||
|
||||
Raises:
|
||||
ValueError: If path is empty
|
||||
"""
|
||||
if not path:
|
||||
raise ValueError("Module path cannot be empty")
|
||||
|
||||
self.path: str = path
|
||||
self.docstring: Optional[str] = docstring
|
||||
self.members: Dict[str, DocObject] = {}
|
||||
|
||||
def add_object(self, obj: DocObject) -> None:
|
||||
"""Add a documentation object to this module.
|
||||
|
||||
Args:
|
||||
obj: The documentation object to add
|
||||
|
||||
Raises:
|
||||
ValueError: If object name conflicts with existing object
|
||||
"""
|
||||
if obj.name in self.members:
|
||||
raise ValueError(f"Object '{obj.name}' already exists in module '{self.path}'")
|
||||
self.members[obj.name] = obj
|
||||
|
||||
def get_object(self, name: str) -> Optional[DocObject]:
|
||||
"""Get a documentation object by name.
|
||||
|
||||
Args:
|
||||
name: The name of the object to retrieve
|
||||
|
||||
Returns:
|
||||
The DocObject if found, None otherwise
|
||||
"""
|
||||
return self.members.get(name)
|
||||
|
||||
def get_public_objects(self) -> List[DocObject]:
|
||||
"""Get all public (non-private) documentation objects.
|
||||
|
||||
Returns:
|
||||
List of DocObjects that are not private
|
||||
"""
|
||||
return [obj for obj in self.members.values() if not obj.is_private()]
|
||||
|
||||
def get_objects_by_kind(self, kind: str) -> List[DocObject]:
|
||||
"""Get all documentation objects of a specific kind.
|
||||
|
||||
Args:
|
||||
kind: The kind of objects to retrieve (e.g., "class", "function")
|
||||
|
||||
Returns:
|
||||
List of DocObjects matching the specified kind
|
||||
"""
|
||||
return [obj for obj in self.members.values() if obj.kind == kind]
|
||||
|
||||
def get_classes(self) -> List[DocObject]:
|
||||
"""Get all class objects in this module.
|
||||
|
||||
Returns:
|
||||
List of DocObjects with kind "class"
|
||||
"""
|
||||
return self.get_objects_by_kind("class")
|
||||
|
||||
def get_functions(self) -> List[DocObject]:
|
||||
"""Get all function objects in this module.
|
||||
|
||||
Returns:
|
||||
List of DocObjects with kind "function"
|
||||
"""
|
||||
return self.get_objects_by_kind("function")
|
||||
|
||||
def has_docstring(self) -> bool:
|
||||
"""Check if this module has a docstring.
|
||||
|
||||
Returns:
|
||||
True if docstring is not None and not empty, False otherwise
|
||||
"""
|
||||
return bool(self.docstring and self.docstring.strip())
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""Check if this module contains any documented objects.
|
||||
|
||||
Returns:
|
||||
True if the module has no members, False otherwise
|
||||
"""
|
||||
return len(self.members) == 0
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return a string representation of the Module.
|
||||
|
||||
Returns:
|
||||
String representation showing path and member count
|
||||
"""
|
||||
return f"Module(path='{self.path}', members={len(self.members)})"
|
||||
@@ -1,210 +0,0 @@
|
||||
"""Navigation structure for doc-forge documentation.
|
||||
|
||||
Navigation provides a hierarchical structure for organizing documentation
|
||||
modules. It is derived automatically from the project structure rather
|
||||
than being manually authored, ensuring consistency between the
|
||||
documentation model and the navigation.
|
||||
|
||||
The navigation is used by renderers to generate table of contents,
|
||||
sidebars, and other navigation elements.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
|
||||
class NavEntry:
|
||||
"""Single navigation entry linking to a module.
|
||||
|
||||
A NavEntry represents one item in the documentation navigation,
|
||||
typically corresponding to a module. It contains a display title
|
||||
and the module path it links to.
|
||||
|
||||
Attributes:
|
||||
title: The display title for this navigation entry
|
||||
module: The import path of the module this entry links to
|
||||
"""
|
||||
|
||||
def __init__(self, title: str, module: str) -> None:
|
||||
"""Initialize a NavEntry.
|
||||
|
||||
Args:
|
||||
title: The display title for this entry
|
||||
module: The import path of the linked module
|
||||
|
||||
Raises:
|
||||
ValueError: If title or module is empty
|
||||
"""
|
||||
if not title:
|
||||
raise ValueError("NavEntry title cannot be empty")
|
||||
if not module:
|
||||
raise ValueError("NavEntry module cannot be empty")
|
||||
|
||||
self.title: str = title
|
||||
self.module: str = module
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return a string representation of the NavEntry.
|
||||
|
||||
Returns:
|
||||
String representation showing title and module
|
||||
"""
|
||||
return f"NavEntry(title='{self.title}', module='{self.module}')"
|
||||
|
||||
|
||||
class Navigation:
|
||||
"""Navigation structure derived from project modules.
|
||||
|
||||
Navigation provides an organized hierarchy for browsing documentation.
|
||||
It is automatically generated from the project's module structure,
|
||||
ensuring that the navigation always reflects the actual available
|
||||
documentation.
|
||||
|
||||
The navigation can be customized by:
|
||||
- Changing the order of entries
|
||||
- Grouping related modules
|
||||
- Providing custom titles
|
||||
|
||||
Attributes:
|
||||
entries: List of navigation entries in order
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize an empty Navigation."""
|
||||
self.entries: List[NavEntry] = []
|
||||
|
||||
def add_entry(self, entry: NavEntry) -> None:
|
||||
"""Add a navigation entry.
|
||||
|
||||
Args:
|
||||
entry: The navigation entry to add
|
||||
"""
|
||||
self.entries.append(entry)
|
||||
|
||||
def add_entry_by_module(self, module: str, title: Optional[str] = None) -> None:
|
||||
"""Add a navigation entry for a module.
|
||||
|
||||
This is a convenience method that creates a NavEntry from a module
|
||||
path. If no title is provided, the module name is used as the title.
|
||||
|
||||
Args:
|
||||
module: The import path of the module
|
||||
title: Optional custom title (defaults to module name)
|
||||
"""
|
||||
if title is None:
|
||||
# Use the last part of the module path as the title
|
||||
title = module.split('.')[-1].replace('_', ' ').title()
|
||||
|
||||
entry = NavEntry(title, module)
|
||||
self.add_entry(entry)
|
||||
|
||||
def get_entry(self, title: str) -> Optional[NavEntry]:
|
||||
"""Get a navigation entry by title.
|
||||
|
||||
Args:
|
||||
title: The title of the entry to find
|
||||
|
||||
Returns:
|
||||
The NavEntry if found, None otherwise
|
||||
"""
|
||||
for entry in self.entries:
|
||||
if entry.title == title:
|
||||
return entry
|
||||
return None
|
||||
|
||||
def get_entry_by_module(self, module: str) -> Optional[NavEntry]:
|
||||
"""Get a navigation entry by module path.
|
||||
|
||||
Args:
|
||||
module: The module path to search for
|
||||
|
||||
Returns:
|
||||
The NavEntry if found, None otherwise
|
||||
"""
|
||||
for entry in self.entries:
|
||||
if entry.module == module:
|
||||
return entry
|
||||
return None
|
||||
|
||||
def remove_entry(self, title: str) -> bool:
|
||||
"""Remove a navigation entry by title.
|
||||
|
||||
Args:
|
||||
title: The title of the entry to remove
|
||||
|
||||
Returns:
|
||||
True if entry was removed, False if not found
|
||||
"""
|
||||
for i, entry in enumerate(self.entries):
|
||||
if entry.title == title:
|
||||
del self.entries[i]
|
||||
return True
|
||||
return False
|
||||
|
||||
def remove_entry_by_module(self, module: str) -> bool:
|
||||
"""Remove a navigation entry by module path.
|
||||
|
||||
Args:
|
||||
module: The module path of the entry to remove
|
||||
|
||||
Returns:
|
||||
True if entry was removed, False if not found
|
||||
"""
|
||||
for i, entry in enumerate(self.entries):
|
||||
if entry.module == module:
|
||||
del self.entries[i]
|
||||
return True
|
||||
return False
|
||||
|
||||
def reorder_entries(self, titles: List[str]) -> None:
|
||||
"""Reorder entries based on provided title order.
|
||||
|
||||
Entries not mentioned in the titles list will maintain their
|
||||
relative order and be placed after the specified entries.
|
||||
|
||||
Args:
|
||||
titles: List of titles in the desired order
|
||||
"""
|
||||
# Create a mapping of title to entry for quick lookup
|
||||
entry_map = {entry.title: entry for entry in self.entries}
|
||||
|
||||
# Build new ordered list
|
||||
ordered_entries = []
|
||||
remaining_entries = list(self.entries)
|
||||
|
||||
# Add entries in specified order
|
||||
for title in titles:
|
||||
if title in entry_map:
|
||||
ordered_entries.append(entry_map[title])
|
||||
# Remove from remaining entries
|
||||
remaining_entries = [e for e in remaining_entries if e.title != title]
|
||||
|
||||
# Add remaining entries in their original order
|
||||
ordered_entries.extend(remaining_entries)
|
||||
|
||||
self.entries = ordered_entries
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""Check if navigation has no entries.
|
||||
|
||||
Returns:
|
||||
True if navigation has no entries, False otherwise
|
||||
"""
|
||||
return len(self.entries) == 0
|
||||
|
||||
def get_module_list(self) -> List[str]:
|
||||
"""Get list of all module paths in navigation.
|
||||
|
||||
Returns:
|
||||
List of module paths in navigation order
|
||||
"""
|
||||
return [entry.module for entry in self.entries]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return a string representation of the Navigation.
|
||||
|
||||
Returns:
|
||||
String representation showing entry count
|
||||
"""
|
||||
return f"Navigation(entries={len(self.entries)})"
|
||||
@@ -1,131 +0,0 @@
|
||||
"""Core documentation object representing a Python entity.
|
||||
|
||||
DocObject is the atomic unit of documentation in doc-forge. It represents
|
||||
any Python entity that can be documented: classes, functions, methods,
|
||||
attributes, constants, etc.
|
||||
|
||||
Each DocObject contains:
|
||||
- Basic metadata (name, kind, path)
|
||||
- Optional signature information
|
||||
- Optional docstring
|
||||
- Nested members (for classes and modules)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, Optional, Set
|
||||
|
||||
|
||||
class DocObject:
|
||||
"""Represents a Python documentation object (class, function, variable, etc.).
|
||||
|
||||
DocObject is the fundamental building block of the documentation model.
|
||||
It captures all essential information about a Python entity in a
|
||||
renderer-agnostic format.
|
||||
|
||||
Attributes:
|
||||
name: The name of the object (e.g., "MyClass", "my_function")
|
||||
kind: The type of object ("class", "function", "method", "attribute", etc.)
|
||||
path: The full import path (e.g., "package.module.MyClass.my_method")
|
||||
signature: Optional function/method signature string
|
||||
docstring: Optional docstring content
|
||||
members: Dictionary of nested member objects
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
kind: str,
|
||||
path: str,
|
||||
signature: Optional[str] = None,
|
||||
docstring: Optional[str] = None,
|
||||
) -> None:
|
||||
"""Initialize a DocObject.
|
||||
|
||||
Args:
|
||||
name: The name of the object
|
||||
kind: The type/kind of object
|
||||
path: Full import path to the object
|
||||
signature: Optional signature for callable objects
|
||||
docstring: Optional docstring content
|
||||
|
||||
Raises:
|
||||
ValueError: If name, kind, or path are empty
|
||||
"""
|
||||
if not name:
|
||||
raise ValueError("DocObject name cannot be empty")
|
||||
if not kind:
|
||||
raise ValueError("DocObject kind cannot be empty")
|
||||
if not path:
|
||||
raise ValueError("DocObject path cannot be empty")
|
||||
|
||||
self.name: str = name
|
||||
self.kind: str = kind
|
||||
self.path: str = path
|
||||
self.signature: Optional[str] = signature
|
||||
self.docstring: Optional[str] = docstring
|
||||
self.members: Dict[str, DocObject] = {}
|
||||
|
||||
def add_member(self, member: DocObject) -> None:
|
||||
"""Add a nested member object.
|
||||
|
||||
This is used for objects that contain other objects, such as
|
||||
classes containing methods and attributes, or modules containing
|
||||
functions and classes.
|
||||
|
||||
Args:
|
||||
member: The member object to add
|
||||
|
||||
Raises:
|
||||
ValueError: If member name conflicts with existing member
|
||||
"""
|
||||
if member.name in self.members:
|
||||
raise ValueError(f"Member '{member.name}' already exists in '{self.name}'")
|
||||
self.members[member.name] = member
|
||||
|
||||
def get_member(self, name: str) -> Optional[DocObject]:
|
||||
"""Get a nested member by name.
|
||||
|
||||
Args:
|
||||
name: The name of the member to retrieve
|
||||
|
||||
Returns:
|
||||
The member object if found, None otherwise
|
||||
"""
|
||||
return self.members.get(name)
|
||||
|
||||
def is_private(self) -> bool:
|
||||
"""Check if this object is considered private.
|
||||
|
||||
Private objects are those whose names start with an underscore.
|
||||
This convention is used to filter out internal implementation
|
||||
details from public documentation.
|
||||
|
||||
Returns:
|
||||
True if the object name starts with underscore, False otherwise
|
||||
"""
|
||||
return self.name.startswith('_')
|
||||
|
||||
def get_public_members(self) -> list[DocObject]:
|
||||
"""Get all public (non-private) member objects.
|
||||
|
||||
Returns:
|
||||
List of member objects that are not private
|
||||
"""
|
||||
return [member for member in self.members.values() if not member.is_private()]
|
||||
|
||||
def has_docstring(self) -> bool:
|
||||
"""Check if this object has a docstring.
|
||||
|
||||
Returns:
|
||||
True if docstring is not None and not empty, False otherwise
|
||||
"""
|
||||
return bool(self.docstring and self.docstring.strip())
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return a string representation of the DocObject.
|
||||
|
||||
Returns:
|
||||
String representation showing name, kind, and path
|
||||
"""
|
||||
return f"DocObject(name='{self.name}', kind='{self.kind}', path='{self.path}')"
|
||||
@@ -1,194 +0,0 @@
|
||||
"""Project representation in the doc-forge documentation model.
|
||||
|
||||
Project is the root container for all documentation in a doc-forge
|
||||
project. It represents the entire codebase being documented and serves
|
||||
as the entry point for all documentation operations.
|
||||
|
||||
A Project contains modules, navigation, and metadata about the
|
||||
codebase being documented.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from .module import Module
|
||||
from .nav import Navigation
|
||||
|
||||
|
||||
class Project:
|
||||
"""Root container for all documentation in a project.
|
||||
|
||||
Project is the top-level object in the doc-forge documentation model.
|
||||
It represents the entire codebase being documented and serves as the
|
||||
central hub for all documentation operations.
|
||||
|
||||
Each Project contains:
|
||||
- Basic metadata (name, version)
|
||||
- All documented modules
|
||||
- Navigation structure for browsing
|
||||
|
||||
The Project is the single source of truth that all renderers and
|
||||
exporters work with, ensuring consistency across all output formats.
|
||||
|
||||
Attributes:
|
||||
name: The name of the project
|
||||
version: Optional version string
|
||||
modules: Dictionary of all modules in the project
|
||||
nav: Navigation structure for the project
|
||||
"""
|
||||
|
||||
def __init__(self, name: str, version: Optional[str] = None) -> None:
|
||||
"""Initialize a Project.
|
||||
|
||||
Args:
|
||||
name: The name of the project
|
||||
version: Optional version string
|
||||
|
||||
Raises:
|
||||
ValueError: If name is empty
|
||||
"""
|
||||
if not name:
|
||||
raise ValueError("Project name cannot be empty")
|
||||
|
||||
self.name: str = name
|
||||
self.version: Optional[str] = version
|
||||
self.modules: Dict[str, Module] = {}
|
||||
self.nav: Navigation = Navigation()
|
||||
|
||||
def add_module(self, module: Module) -> None:
|
||||
"""Add a module to the project.
|
||||
|
||||
When a module is added, it's also automatically added to the
|
||||
navigation structure if not already present.
|
||||
|
||||
Args:
|
||||
module: The module to add
|
||||
|
||||
Raises:
|
||||
ValueError: If module path conflicts with existing module
|
||||
"""
|
||||
if module.path in self.modules:
|
||||
raise ValueError(f"Module '{module.path}' already exists in project")
|
||||
|
||||
self.modules[module.path] = module
|
||||
|
||||
# Add to navigation if not already present
|
||||
if not self.nav.get_entry_by_module(module.path):
|
||||
self.nav.add_entry_by_module(module.path)
|
||||
|
||||
def get_module(self, path: str) -> Optional[Module]:
|
||||
"""Get a module by its import path.
|
||||
|
||||
Args:
|
||||
path: The import path of the module to retrieve
|
||||
|
||||
Returns:
|
||||
The Module if found, None otherwise
|
||||
"""
|
||||
return self.modules.get(path)
|
||||
|
||||
def get_all_modules(self) -> List[Module]:
|
||||
"""Get all modules in the project.
|
||||
|
||||
Returns:
|
||||
List of all Module objects in the project
|
||||
"""
|
||||
return list(self.modules.values())
|
||||
|
||||
def get_public_modules(self) -> List[Module]:
|
||||
"""Get all modules with public (non-empty) content.
|
||||
|
||||
Returns:
|
||||
List of modules that have at least one public object
|
||||
"""
|
||||
return [
|
||||
module for module in self.modules.values()
|
||||
if module.get_public_objects()
|
||||
]
|
||||
|
||||
def remove_module(self, path: str) -> bool:
|
||||
"""Remove a module from the project.
|
||||
|
||||
Args:
|
||||
path: The import path of the module to remove
|
||||
|
||||
Returns:
|
||||
True if module was removed, False if not found
|
||||
"""
|
||||
if path in self.modules:
|
||||
del self.modules[path]
|
||||
# Also remove from navigation
|
||||
self.nav.remove_entry_by_module(path)
|
||||
return True
|
||||
return False
|
||||
|
||||
def has_module(self, path: str) -> bool:
|
||||
"""Check if a module exists in the project.
|
||||
|
||||
Args:
|
||||
path: The import path to check
|
||||
|
||||
Returns:
|
||||
True if module exists, False otherwise
|
||||
"""
|
||||
return path in self.modules
|
||||
|
||||
def get_module_count(self) -> int:
|
||||
"""Get the total number of modules in the project.
|
||||
|
||||
Returns:
|
||||
Number of modules in the project
|
||||
"""
|
||||
return len(self.modules)
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""Check if the project has no modules.
|
||||
|
||||
Returns:
|
||||
True if project has no modules, False otherwise
|
||||
"""
|
||||
return len(self.modules) == 0
|
||||
|
||||
def get_total_object_count(self) -> int:
|
||||
"""Get the total count of all documentation objects.
|
||||
|
||||
Returns:
|
||||
Total number of DocObjects across all modules
|
||||
"""
|
||||
return sum(len(module.members) for module in self.modules.values())
|
||||
|
||||
def get_modules_by_pattern(self, pattern: str) -> List[Module]:
|
||||
"""Get modules matching a pattern.
|
||||
|
||||
Args:
|
||||
pattern: Pattern to match against module paths (supports wildcards)
|
||||
|
||||
Returns:
|
||||
List of modules whose paths match the pattern
|
||||
"""
|
||||
import fnmatch
|
||||
|
||||
return [
|
||||
module for module in self.modules.values()
|
||||
if fnmatch.fnmatch(module.path, pattern)
|
||||
]
|
||||
|
||||
def rebuild_navigation(self) -> None:
|
||||
"""Rebuild navigation from current modules.
|
||||
|
||||
This clears the existing navigation and rebuilds it from the
|
||||
current set of modules, ensuring navigation is in sync with
|
||||
the actual project structure.
|
||||
"""
|
||||
self.nav = Navigation()
|
||||
for module_path in sorted(self.modules.keys()):
|
||||
self.nav.add_entry_by_module(module_path)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return a string representation of the Project.
|
||||
|
||||
Returns:
|
||||
String representation showing name and module count
|
||||
"""
|
||||
return f"Project(name='{self.name}', modules={len(self.modules)})"
|
||||
Reference in New Issue
Block a user