Add Folder Export Feature with URL Support #96
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.
Add Folder Export Feature with URL Support
Summary
This PR adds a new
folderscommand that enables exporting all pages within a Confluence folder and its subfolders to Markdown. The feature includes:Core Functionality
https://company.atlassian.net/wiki/spaces/MYSPACE/folders/123456)/api/v2/folders/endpoints for folder operationsUsage
Export folder by ID:
Export folder by URL (same as pages command):
Export multiple folders (mixing IDs and URLs):
Implementation Details
New
Folderclass (confluence_markdown_exporter/confluence.py):from_id(folder_id): Fetch and create Folder from IDfrom_url(folder_url): Parse folder URL and create Folder from extracted ID (supports multiple URL patterns)export(): Export all pages with warning for empty folderspagesproperty: Recursively collects all page IDs from folder hierarchyAPI helper functions:
get_folder_by_id(): Fetches folder metadata using REST API v2get_folder_children(): Fetches all children (pages and subfolders) with paginationCLI integration (
confluence_markdown_exporter/main.py):folderscommand following the same pattern aspagesandspacescommandshttp://orhttps://prefix)--output-pathparameterDocumentation:
README.mdwith folder export section and examplesTest Plan
Unit Tests
TestGetFolderById: Tests for folder fetching and 404 handlingTestGetFolderChildren: Tests for pagination, empty folders, and HTTP errorsTestFolderClass: Tests for Folder class methods including:from_json()andfrom_id()creation methodsfrom_url()with multiple URL patterns (/spaces/SPACE/folders/ID,/spaces/SPACE/pages/folders/ID, generic patterns)ValueError)pagesproperty with recursive traversalexport()method with and without pagesCode Quality
Manual Testing
The feature has been tested with:
Test Infrastructure
tests/conftest.pyto mock the module-level Confluence instance during test collectionChanges
Modified files:
README.md: Added folder export documentation and examplesconfluence_markdown_exporter/confluence.py: AddedFolderclass and API helpers (~160 lines)confluence_markdown_exporter/main.py: Addedfolderscommand (~20 lines)tests/conftest.py: Fixed test infrastructure for module-level importstests/unit/test_confluence.py: Added comprehensive test suite (~250 lines)tests/unit/test_main.py: Updated command list testBackward Compatibility
✅ This feature is fully backward compatible: