Skip to content

page update : --pretty引数を追加しました。#34

Merged
yuji38kwmt merged 7 commits intomainfrom
20260111-1
Jan 12, 2026
Merged

page update : --pretty引数を追加しました。#34
yuji38kwmt merged 7 commits intomainfrom
20260111-1

Conversation

@yuji38kwmt
Copy link
Copy Markdown
Collaborator

No description provided.

- Changed Python version requirement from ^3.9 to ^3.10.
- Updated ruff dependency to the latest version.
- Adjusted target version for ruff from py39 to py310.
- Removed unnecessary linting ignores for missing type hints on self and cls.
- Cleaned up formatting in the pyproject.toml file.
Copilot AI review requested due to automatic review settings January 12, 2026 06:38
@yuji38kwmt yuji38kwmt changed the title 20260111 1 page update : --pretty引数を追加しました。 Jan 12, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the Confluence CLI project with maintenance improvements and a new HTML/XML formatting feature. The changes remove company-specific references, modernize Python typing syntax, update dependencies, and add functionality to format page content output.

Changes:

  • Updates minimum Python version from 3.9 to 3.10 and modernizes type hints to use PEP 604 union syntax (| instead of typing.Optional)
  • Adds lxml dependency and implements a new --pretty option for formatting HTML/XML output in the get_body command
  • Removes company-specific references from documentation and configuration to make the project more generic

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyproject.toml Updates Python version to 3.10, adds lxml dependency, removes ruff version constraint, removes deprecated ruff rules (ANN101/ANN102), and removes poetry-dynamic-versioning format configuration
docs/user_guide/getting_started.rst Updates Python version requirement and removes company-specific Confluence URL reference
docs/conf.py Removes empty footer configuration
docs/command_reference/page/get_body.rst Fixes title, adds documentation for storage format and representation options
confluence/page/get_page_body.py Adds format_html function and --pretty option, modernizes imports, adds BodyRepresentation enum documentation
confluence/page/update_page.py Refactors imports to use relative import for cli module
confluence/page/subcommand.py Modernizes type hints and refactors imports
confluence/local/subcommand.py Removes Optional import and modernizes type hints
confluence/content/subcommand.py Modernizes type hints and refactors imports
confluence/content/get_content_by_id.py Refactors imports to use relative import
confluence/common/utils.py Modernizes type hints
confluence/common/cli.py Modernizes type hints and uses removesuffix() method
confluence/common/api.py Modernizes type hints throughout API class methods
confluence/attachment/subcommand.py Modernizes type hints and refactors imports
confluence/attachment/get_attachment.py Refactors imports to use relative import
confluence/attachment/delete_attachment.py Refactors imports and adds spacing around + operator in f-strings
confluence/attachment/create_attachment.py Refactors imports and adds spacing around + operator in f-strings
confluence/main.py Removes Optional import and modernizes type hints
README.md Removes company-specific description, updates CI badge, and changes example page ID

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +52
HTMLを整形します。

Args:
content: 整形対象のHTML文字列

Returns:
整形されたHTML文字列
"""
try:
# HTMLフラグメントをパースして整形
root = html.fromstring(content)
etree.indent(root, space=" ")
return html.tostring(root, encoding="unicode")
except Exception:
logger.warning("HTML整形に失敗しました。", exc_info=True)
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name format_html and its documentation state it formats HTML, but the help text on line 79 mentions "XMLまたはHTMLを整形して出力します" (formats XML or HTML). However, the implementation uses html.fromstring() which is specifically for parsing HTML, not XML. For the STORAGE representation (which is XML format according to line 23), this function may not properly format the content and could fail or produce incorrect results. Consider either:

  1. Renaming to clarify it only handles HTML representations, or
  2. Updating the implementation to detect and handle XML content separately using etree.fromstring() for XML content
Suggested change
HTMLを整形します
Args:
content: 整形対象のHTML文字列
Returns:
整形されたHTML文字列
"""
try:
# HTMLフラグメントをパースして整形
root = html.fromstring(content)
etree.indent(root, space=" ")
return html.tostring(root, encoding="unicode")
except Exception:
logger.warning("HTML整形に失敗しました。", exc_info=True)
XMLまたはHTMLを整形します
Args:
content: 整形対象のXMLまたはHTML文字列
Returns:
整形されたXMLまたはHTML文字列
"""
try:
# まずXMLとしてパースを試みる(STORAGE表現など)
try:
root = etree.fromstring(content)
etree.indent(root, space=" ")
return etree.tostring(root, encoding="unicode")
except etree.XMLSyntaxError:
# XMLとしてパースできない場合はHTMLとしてパースして整形
root = html.fromstring(content)
etree.indent(root, space=" ")
return html.tostring(root, encoding="unicode")
except Exception:
logger.warning("XML/HTML整形に失敗しました。", exc_info=True)

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +53
def format_html(content: str) -> str:
"""
HTMLを整形します。

Args:
content: 整形対象のHTML文字列

Returns:
整形されたHTML文字列
"""
try:
# HTMLフラグメントをパースして整形
root = html.fromstring(content)
etree.indent(root, space=" ")
return html.tostring(root, encoding="unicode")
except Exception:
logger.warning("HTML整形に失敗しました。", exc_info=True)
return content
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new format_html function and --pretty option lack test coverage. Since the repository has test infrastructure (tests directory with pytest), and there's a test for the local module's convert functionality, new utility functions like format_html should have corresponding tests to verify correct behavior, especially for edge cases and error handling.

Copilot uses AI. Check for mistakes.
"""HTML representation for viewing, but with absolute urls, instead of relative urls in the markup, and macros are rendered as though it is viewed by an anonymous user.""" # noqa: E501


def format_html(content: str) -> str:
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is named format_html but the help text on line 79 and the docstring on line 38 claim it handles both XML and HTML. This creates ambiguity about the function's actual purpose. Either rename the function to better reflect what it actually does (e.g., format_content if it should handle both, or keep format_html if it only handles HTML), or update the documentation to accurately describe its capabilities.

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +44
HTMLを整形します。

Args:
content: 整形対象のHTML文字列

Returns:
整形されたHTML文字列
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation incorrectly states the function formats HTML ("HTMLを整形します"), but according to the help text on line 79, it should format both XML and HTML. Update the docstring to accurately reflect that the function handles both XML and HTML content, not just HTML.

Suggested change
HTMLを整形します
Args:
content: 整形対象のHTML文字列
Returns:
整形されたHTML文字列
XMLまたはHTMLを整形します
Args:
content: 整形対象のXMLまたはHTML文字列
Returns:
整形されたXMLまたはHTML文字列

Copilot uses AI. Check for mistakes.
root = html.fromstring(content)
etree.indent(root, space=" ")
return html.tostring(root, encoding="unicode")
except Exception:
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broad exception handler catches all exceptions without specifying which exceptions are expected. This makes it difficult to distinguish between expected parsing errors and unexpected errors (e.g., bugs in the code). Consider catching specific exceptions like lxml.etree.XMLSyntaxError, lxml.etree.ParserError, or ValueError that are expected during HTML parsing, and let other unexpected exceptions propagate.

Suggested change
except Exception:
except (etree.XMLSyntaxError, etree.ParserError, ValueError):

Copilot uses AI. Check for mistakes.
@yuji38kwmt yuji38kwmt merged commit b1a324f into main Jan 12, 2026
4 checks passed
@yuji38kwmt yuji38kwmt deleted the 20260111-1 branch January 12, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants