Skip to content

Add APA, IEEE, and Chicago citation styles#34

Merged
wenh06 merged 12 commits intomasterfrom
feature/more-styles
Mar 15, 2026
Merged

Add APA, IEEE, and Chicago citation styles#34
wenh06 merged 12 commits intomasterfrom
feature/more-styles

Conversation

@wenh06
Copy link
Contributor

@wenh06 wenh06 commented Mar 14, 2026

Implements three new citation styles (APA 7th Edition, IEEE, and Chicago 17th Edition) alongside the existing GB/T 7714-2015 style.

New Style Classes

  • APAStyle - APA 7th Edition format
  • IEEEStyle - IEEE format
  • ChicagoStyle - Chicago 17th Edition (Notes and Bibliography)

Supported Entry Types

  • Article, Book, InProceedings (all styles)
  • PhD Thesis, Master's Thesis (IEEE, GB/T 7714)
  • Technical Report (GB/T 7714)

@wenh06 wenh06 requested review from Copilot and kjs11 March 14, 2026 13:18
@wenh06 wenh06 self-assigned this Mar 14, 2026
@wenh06 wenh06 enabled auto-merge March 14, 2026 13:18
@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.55%. Comparing base (beaadf8) to head (f9788f1).
⚠️ Report is 20 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #34      +/-   ##
==========================================
+ Coverage   98.05%   98.55%   +0.49%     
==========================================
  Files          10       13       +3     
  Lines        1438     1795     +357     
==========================================
+ Hits         1410     1769     +359     
+ Misses         28       26       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

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

Adds new local Pybtex-based citation formatting styles (APA 7, IEEE, Chicago 17) to complement the existing GB/T 7714 support, and expands the test suite to validate expected rendered outputs.

Changes:

  • Introduce APAStyle, IEEEStyle, and ChicagoStyle implementations under bib_lookup/styles/.
  • Update BibLookup to format format="text" locally (via BibTeX parsing + Pybtex templates) for supported styles.
  • Replace/expand style tests with example-driven expected outputs and additional coverage tests.

Reviewed changes

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

Show a summary per file
File Description
bib_lookup/bib_lookup.py Routes format="text" for supported styles through local Pybtex formatting and forces BibTeX retrieval.
bib_lookup/styles/apa.py Adds APA 7th Edition formatting templates and author-name rules.
bib_lookup/styles/ieee.py Adds IEEE formatting templates plus month/pages helpers and author-name rules.
bib_lookup/styles/chicago.py Adds Chicago 17th (Notes & Bibliography) formatting templates and author-name rules.
bib_lookup/styles/gbt7714.py Updates GB/T template behavior and name formatting logic used by local rendering.
bib_lookup/styles/__init__.py Exports the new styles from the package.
test/test_styles.py Reworks tests around a shared example corpus and adds coverage-oriented assertions.
.github/workflows/publish.yml Bumps artifact upload/download GitHub Actions versions.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +131 to +136
# Test IEEE style - add label [1] as pybtex would
ieee_style = IEEEStyle()
ieee_template = ieee_style.get_article_template(entry)
ieee_result = str(ieee_template.format_data({"entry": entry, "bib_data": bib_data, "style": ieee_style})).strip()
ieee_result_with_label = f"[1] {ieee_result}"
assert (
Comment on lines +94 to +101
surname = " ".join(parts).upper() # GB/T 7714 requires uppercase surnames
initials_list = []
for names_list in [person.first_names, person.middle_names]:
for name in names_list:
if name:
initials_list.append(name[0])

initials_list.append(name[0].upper()) # Uppercase initials
initials = " ".join(initials_list)
return f"{surname} {initials}".strip()
Comment on lines +537 to +540
# For APA/Chicago style, we prefer their default max_names (20/10)
# if the global max_names is still at default (3)
if style.lower() in ["apa", "chicago"] and self.max_names == 3:
custom_style = style_class()
Comment on lines +177 to +184
if "doi" in e.fields:
doi = e.fields["doi"]
if not doi.startswith("http"):
doi = f"https://doi.org/{doi}"
template = join(sep=". ")[template, doi]
if "url" in e.fields:
# Add URL even if DOI is present (per expected output)
template = join(sep=". ")[template, field("url")]
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2da42d4b33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

join(sep=": ")[
join[optional_field("volume"), optional["(", field("number"), ")"]],
optional[field("pages")],
field("pages"),

Choose a reason for hiding this comment

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

P1 Badge Keep GB/T article pages optional during formatting

Using field("pages") makes page numbers mandatory for every GB/T article, but many DOI/Crossref records legitimately omit pages (online-first articles, article-number journals, etc.); when that happens the template evaluation raises and BibLookup.__call__ falls back to default_err, so text citation lookup fails for otherwise valid entries. This was previously tolerant via an optional pages field and should remain optional.

Useful? React with 👍 / 👎.

optional[field("pages")],
],
join(sep=": ")[optional_field("address"), field("publisher")],
join(sep=": ")[field("year"), field("pages")],

Choose a reason for hiding this comment

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

P1 Badge Keep GB/T conference pages optional during formatting

The inproceedings template now requires pages unconditionally, so conference entries without page metadata raise during formatting and end up as lookup errors in text mode. Since missing pages are common in upstream metadata, this turns valid entries into failures and regresses previous behavior where pages were optional.

Useful? React with 👍 / 👎.

return ", ".join(formatted_persons[:-1]) + f", and {formatted_persons[-1]}"
else:
# Truncated case
persons_to_format = persons[:7]

Choose a reason for hiding this comment

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

P2 Badge Honor configured Chicago author limit in truncation

The truncation branch ignores self.limit and always takes persons[:7], so when callers set a custom max_names (propagated to ChicagoStyle), output can include more authors than configured before adding et al (for example, limit 3 can still print up to 7 names). This makes the max_names setting ineffective for Chicago output.

Useful? React with 👍 / 👎.

wenh06 and others added 7 commits March 14, 2026 22:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wenh06 wenh06 added this pull request to the merge queue Mar 15, 2026
Merged via the queue into master with commit bb921f5 Mar 15, 2026
8 checks passed
@kjs11 kjs11 deleted the feature/more-styles branch March 15, 2026 14:10
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.

3 participants