API Reference¶
This section provides detailed API documentation for the jarkdown components.
Main Module¶
Jarkdown - Export Jira issues to markdown with attachments.
JiraApiClient¶
- class jarkdown.jira_api_client.JiraApiClient(domain, email, api_token)[source]¶
Bases:
objectHandles all communication with the Jira Cloud REST API.
The JiraApiClient handles all communication with the Jira REST API.
Example usage:
from jarkdown.jira_api_client import JiraApiClient client = JiraApiClient( domain="company.atlassian.net", email="user@company.com", api_token="your_token" ) issue_data = client.get_issue("PROJ-123")
- __init__(domain, email, api_token)[source]¶
Initialize the Jira API client.
- Parameters:
domain – Jira domain (e.g., ‘company.atlassian.net’)
email – User email for authentication
api_token – API token for authentication
- fetch_issue(issue_key)[source]¶
Fetch issue data from Jira API.
- Parameters:
issue_key – The Jira issue key (e.g., ‘PROJ-123’)
- Returns:
Raw JSON response from Jira API
- Return type:
- Raises:
AuthenticationError – If authentication fails
IssueNotFoundError – If issue is not found
JiraApiError – For other API errors
- get_attachment_content_url(attachment)[source]¶
Get the download URL for an attachment.
- Parameters:
attachment – Attachment metadata from Jira API
- Returns:
The content URL for downloading the attachment
- Return type:
- download_attachment_stream(content_url)[source]¶
Stream download an attachment.
- Parameters:
content_url – The URL to download the attachment from
- Returns:
Streaming response object
- Return type:
requests.Response
- Raises:
JiraApiError – If download fails
AttachmentHandler¶
- class jarkdown.attachment_handler.AttachmentHandler(api_client)[source]¶
Bases:
objectManages downloading and saving of issue attachments.
The AttachmentHandler manages downloading and saving attachments.
Example usage:
from jarkdown.attachment_handler import AttachmentHandler handler = AttachmentHandler(auth_session, verbose=True) downloaded = handler.download_attachments( attachments_data, output_dir="/path/to/output" )
- __init__(api_client)[source]¶
Initialize the attachment handler.
- Parameters:
api_client – JiraApiClient instance for API communication
- download_attachment(attachment, output_dir)[source]¶
Download a single attachment.
- Parameters:
attachment – Attachment metadata from Jira API
output_dir – Directory to save the attachment to
- Returns:
- Information about the downloaded attachment including
filename, original_filename, mime_type, and path
- Return type:
- Raises:
AttachmentDownloadError – If download fails
MarkdownConverter¶
- class jarkdown.markdown_converter.MarkdownConverter(base_url, domain)[source]¶
Bases:
objectConverts Jira issue data into Markdown format.
The MarkdownConverter transforms Jira HTML content to clean Markdown.
Example usage:
from jarkdown.markdown_converter import MarkdownConverter converter = MarkdownConverter() markdown_content = converter.convert_issue( issue_data, attachment_mapping )
- __init__(base_url, domain)[source]¶
Initialize the markdown converter.
- Parameters:
base_url – Base URL of the Jira instance (e.g., ‘https://company.atlassian.net’)
domain – Jira domain (e.g., ‘company.atlassian.net’)
- convert_html_to_markdown(html_content)[source]¶
Convert HTML content to Markdown.
- Parameters:
html_content – HTML string to convert
- Returns:
Converted markdown content
- Return type:
- replace_attachment_links(markdown_content, downloaded_attachments)[source]¶
Replace Jira attachment URLs with local file references.
- Parameters:
markdown_content – Markdown content with Jira attachment URLs
downloaded_attachments – List of downloaded attachment info
- Returns:
Markdown content with local file references
- Return type:
Exceptions¶
Custom exceptions for jarkdown.
Custom exceptions for error handling.
Exception Hierarchy:
JarkdownError
├── ConfigurationError
├── JiraApiError
│ ├── AuthenticationError
│ └── IssueNotFoundError
└── AttachmentDownloadError
Example usage:
from jarkdown.exceptions import AuthenticationError, IssueNotFoundError
try:
issue = client.get_issue(issue_key)
except AuthenticationError:
print("Invalid credentials")
except IssueNotFoundError:
print(f"Issue {issue_key} not found")
- exception jarkdown.exceptions.JarkdownError[source]¶
Bases:
ExceptionBase exception for all jarkdown errors.
- exception jarkdown.exceptions.JiraApiError(message, status_code=None, response=None)[source]¶
Bases:
JarkdownErrorRaised when there’s an error communicating with the Jira API.
- exception jarkdown.exceptions.AuthenticationError(message, status_code=None, response=None)[source]¶
Bases:
JiraApiErrorRaised when authentication with Jira fails.
- exception jarkdown.exceptions.IssueNotFoundError(message, status_code=None, response=None)[source]¶
Bases:
JiraApiErrorRaised when the requested issue is not found.
- exception jarkdown.exceptions.AttachmentDownloadError(message, filename=None)[source]¶
Bases:
JarkdownErrorRaised when there’s an error downloading an attachment.
- exception jarkdown.exceptions.ConfigurationError[source]¶
Bases:
JarkdownErrorRaised when there’s a configuration problem.