Skip to content

Conversation

@wenh06
Copy link
Contributor

@wenh06 wenh06 commented Nov 17, 2025

Fix errors when no global config pseudocode2_options is set.

Copilot AI review requested due to automatic review settings November 17, 2025 03:18
@wenh06 wenh06 self-assigned this Nov 17, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@wenh06 wenh06 added the bug Something isn't working label Nov 17, 2025
Copilot finished reviewing on behalf of wenh06 November 17, 2025 03:20
Copy link

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 PR fixes errors that occur when the global configuration pseudocode2_options is not set in the Sphinx config file. It also includes documentation improvements and examples for custom indentation control.

  • Adds a defensive check to handle None values for global_opts in the directive code
  • Updates documentation to improve clarity and fix minor wording issues
  • Adds a new "Tips" section demonstrating manual indentation control using LaTeX's \hspace command

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
sphinxcontrib/pseudocode2/__init__.py Adds null safety check for global_opts to prevent errors when config is not set
docs/source/index.rst Fixes heading underline length, improves wording, updates links, and adds Tips section with indentation examples
docs/source/demo.rst Adds reference anchor and example lines demonstrating custom indentation with \hspace
README.md Improves wording, updates links, adds period to priority rule, and includes Tips section with indentation examples

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

env = getattr(self, "env", None)
app = getattr(env, "app", None) if env is not None else None
global_opts = getattr(app.config, "pseudocode2_options", {}) if app is not None else {}
global_opts = global_opts if global_opts is not None else {}
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

This check is redundant. Line 62 uses getattr(app.config, 'pseudocode2_options', {}) which already provides {} as the default when the attribute doesn't exist. The getattr function never returns None in this case—it returns the provided default {}. If a user explicitly sets pseudocode2_options = None in their config, that would be a configuration error that should be caught earlier or documented as invalid.

Suggested change
global_opts = global_opts if global_opts is not None else {}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR solves the case where app.config has the attribute 'pseudocode2_options' whose value is None.

Tips
=====================================================

- Custom (Manual) indentation Control: ``psuedo.js`` and ``algorithmic`` do not have a built-in way (a single command
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'psuedo.js' to 'pseudo.js'.

Suggested change
- Custom (Manual) indentation Control: ``psuedo.js`` and ``algorithmic`` do not have a built-in way (a single command
- Custom (Manual) indentation Control: ``pseudocode.js`` and ``algorithmic`` do not have a built-in way (a single command

Copilot uses AI. Check for mistakes.
README.md Outdated

## Tips

- Custom (Manual) indentation Control: ``psuedo.js`` and ``algorithmic`` do not have a built-in way (a single command
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'psuedo.js' to 'pseudo.js'.

Suggested change
- Custom (Manual) indentation Control: ``psuedo.js`` and ``algorithmic`` do not have a built-in way (a single command
- Custom (Manual) indentation Control: ``pseudo.js`` and ``algorithmic`` do not have a built-in way (a single command

Copilot uses AI. Check for mistakes.
@wenh06 wenh06 merged commit 44c4e12 into master Nov 17, 2025
9 checks passed
@wenh06 wenh06 deleted the fix-empty-global-conf branch November 17, 2025 03:31
@wenh06 wenh06 restored the fix-empty-global-conf branch November 17, 2025 03:34
@wenh06 wenh06 deleted the fix-empty-global-conf branch November 17, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants