Add Folder Export Feature with URL Support#96
Open
AlessandroAnnini wants to merge 2 commits into
Open
Conversation
- Add Folder class to handle folder exports with recursive traversal - Add folders CLI command to export pages from one or more folders - Implement get_folder_by_id and get_folder_children API helpers - Add cursor-based pagination for folder children - Add comprehensive unit tests for Folder class and API functions - Update README with folder export documentation and examples - Handle empty folders with warning messages - Support multiple folder IDs in single command
rodrigo398
approved these changes
Oct 3, 2025
- Add Folder.from_url() method to parse folder URLs and extract IDs - Support multiple URL patterns: /spaces/SPACE/folders/ID, /spaces/SPACE/pages/folders/ID - Update folders command to accept both IDs and URLs with automatic detection - Add comprehensive unit tests for URL parsing (4 new tests covering different patterns) - Update README.md with folder URL usage examples - Fix test infrastructure in conftest.py to handle module-level Confluence instance All 89 unit tests passing. Folder export now supports the same flexible input methods as page exports, allowing users to easily export folders by copying URLs from their browser.
Author
|
Fixed! |
Owner
|
@AlessandroAnnini Thanks for this PR. Can you solve the merge conflict and adjust the code to the latest version? As was done for the other commands, can you also add an additional singular "folder" command. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: