Classes
MoveOperation
dataclass
A planned content move operation.
MoveOperation
dataclass A planned content move operation.
Attributes
| Name | Type | Description |
|---|---|---|
source |
str |
Source path (relative to content dir) |
destination |
str |
Destination path (relative to content dir) |
reason |
str |
Why this move is happening |
Internal Methods 1
__str__
__str__
def __str__(self) -> str
Returns
str
LinkUpdate
dataclass
A link that needs to be updated.
LinkUpdate
dataclass A link that needs to be updated.
Attributes
| Name | Type | Description |
|---|---|---|
file_path |
str |
File containing the link |
old_link |
str |
Current link target |
new_link |
str |
New link target |
line |
int |
Line number in file |
context |
str |
Surrounding text context |
Redirect
dataclass
A redirect rule for moved content.
Redirect
dataclass A redirect rule for moved content.
Attributes
| Name | Type | Description |
|---|---|---|
from_path |
str |
Old URL path |
to_path |
str |
New URL path |
status_code |
int |
HTTP status code (301 permanent, 302 temporary) |
Methods 3
to_nginx
Generate nginx redirect rule.
to_nginx
def to_nginx(self) -> str
Generate nginx redirect rule.
Returns
str
to_netlify
Generate Netlify _redirects format.
to_netlify
def to_netlify(self) -> str
Generate Netlify _redirects format.
Returns
str
to_apache
Generate Apache .htaccess rule.
to_apache
def to_apache(self) -> str
Generate Apache .htaccess rule.
Returns
str
MovePreview
dataclass
Preview of what a move operation would do.
MovePreview
dataclass Preview of what a move operation would do.
Attributes
| Name | Type | Description |
|---|---|---|
operation |
MoveOperation |
The move operation being previewed |
affected_links |
list[LinkUpdate] |
Links that would need updating |
redirects_needed |
list[Redirect] |
Redirects that would be generated |
warnings |
list[str] |
Any warnings about the move |
can_proceed |
bool |
Whether the move can safely proceed |
Methods 1
format_summary
Format preview as summary.
format_summary
def format_summary(self) -> str
Format preview as summary.
Returns
str
PageDraft
dataclass
A draft of a new or modified page.
Used for split/merge operations to preview changes before applying.
PageDraft
dataclass A draft of a new or modified page.
Used for split/merge operations to preview changes before applying.
Attributes
| Name | Type | Description |
|---|---|---|
path |
str |
Target path for the page |
title |
str |
Page title |
content |
str |
Page content (markdown) |
frontmatter |
dict[str, Any] |
Page frontmatter |
source_pages |
list[str] |
Original pages this was derived from |
Methods 1
format_preview
Format as preview.
format_preview
def format_preview(self, max_lines: int = 20) -> str
Format as preview.
Parameters 1
max_lines |
int |
Returns
str
ContentMigrator
Tool for safely restructuring content.
Helps move, split, merge, and reorganize content while main…
ContentMigrator
Tool for safely restructuring content.
Helps move, split, merge, and reorganize content while maintaining link integrity and generating necessary redirects.
Creation:
migrator = ContentMigrator(site=site)
DebugToolMethods 6
analyze
Analyze content structure for migration opportunities.
analyze
def analyze(self) -> DebugReport
Analyze content structure for migration opportunities.
Returns
DebugReport with structure analysisDebugReport
—
preview_move
Preview what would happen if a file is moved.
preview_move
def preview_move(self, source: str, destination: str) -> MovePreview
Preview what would happen if a file is moved.
Parameters 2
source |
str |
Source path (relative to content dir) |
destination |
str |
Destination path |
Returns
MovePreview with affected links and redirectsMovePreview
—
execute_move
Execute a previewed move operation.
execute_move
def execute_move(self, preview: MovePreview, update_links: bool = True, create_redirects: bool = True, dry_run: bool = False) -> list[str]
Execute a previewed move operation.
Parameters 4
preview |
MovePreview |
Move preview from preview_move() |
update_links |
bool |
Whether to update links in other files |
create_redirects |
bool |
Whether to generate redirect rules |
dry_run |
bool |
If True, only report what would be done |
Returns
List of actions taken (or that would be taken)list[str]
—
split_page
Split a large page into multiple smaller pages.
split_page
def split_page(self, page_path: str, sections: list[str], output_dir: str | None = None) -> list[PageDraft]
Split a large page into multiple smaller pages.
Parameters 3
page_path |
str |
Path to the page to split |
sections |
list[str] |
List of heading names to split at |
output_dir |
str | None |
Optional output directory for new pages |
Returns
List of PageDraft objects for the new pageslist[PageDraft]
—
merge_pages
Merge multiple pages into one.
merge_pages
def merge_pages(self, page_paths: list[str], output_path: str, title: str | None = None) -> PageDraft
Merge multiple pages into one.
Parameters 3
page_paths |
list[str] |
Paths to pages to merge |
output_path |
str |
Output path for merged page |
title |
str | None |
Optional title for merged page |
Returns
PageDraft for the merged pagePageDraft
—
generate_redirects
Generate redirect rules for moved content.
generate_redirects
def generate_redirects(self, moves: list[MoveOperation], output_format: str = 'netlify') -> str
Generate redirect rules for moved content.
Parameters 2
moves |
list[MoveOperation] |
List of move operations |
output_format |
str |
Output format (netlify, nginx, apache) |
Returns
Redirect rules in requested formatstr
—
Internal Methods 8
_find_structure_issues
Find potential structure issues in content.
_find_structure_issues
def _find_structure_issues(self) -> list[DebugFinding]
Find potential structure issues in content.
Returns
list[DebugFinding]
_is_in_navigation
Check if page is in site navigation.
_is_in_navigation
def _is_in_navigation(self, page: Any) -> bool
Check if page is in site navigation.
Parameters 1
page |
Any |
Returns
bool
_path_to_url
Convert file path to URL.
_path_to_url
def _path_to_url(self, path: str) -> str
Convert file path to URL.
Parameters 1
path |
str |
Returns
str
_links_match
Check if a link matches a target URL.
_links_match
def _links_match(self, link: str, target_url: str) -> bool
Check if a link matches a target URL.
Parameters 2
link |
str |
|
target_url |
str |
Returns
bool
_update_link
Update a link to point to new location.
_update_link
def _update_link(self, old_link: str, old_url: str, new_url: str) -> str
Update a link to point to new location.
Parameters 3
old_link |
str |
|
old_url |
str |
|
new_url |
str |
Returns
str
_update_file_link
Update a link in a file.
_update_file_link
def _update_file_link(self, link_update: LinkUpdate) -> None
Update a link in a file.
Parameters 1
link_update |
LinkUpdate |
_slugify
Convert text to URL slug.
_slugify
def _slugify(self, text: str) -> str
Convert text to URL slug.
Parameters 1
text |
str |
Returns
str
_generate_recommendations
Generate recommendations based on analysis.
_generate_recommendations
def _generate_recommendations(self, report: DebugReport) -> list[str]
Generate recommendations based on analysis.
Parameters 1
report |
DebugReport |
Returns
list[str]