Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting from raw in code citations to bibtex (1/N). #5149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zivy
Copy link
Member

@zivy zivy commented Jan 23, 2025

First PR out of N, converting raw inline citations with various styles to using a bibliography database and the doxygen cite command. Will take multiple PRs to fully complete #3662.

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module area:Documentation Issues affecting the Documentation module labels Jan 23, 2025
@zivy zivy requested review from jhlegarreta and dzenanz January 23, 2025 16:30
@zivy
Copy link
Member Author

zivy commented Jan 23, 2025

@dave3d is there a way to have the spellchecker ignore the bibliography tags which are used by the doxygen \cite command? Other than listing all the tags in the itk_dict.txt file.

@dave3d
Copy link
Member

dave3d commented Jan 23, 2025

@dave3d is there a way to have the spellchecker ignore the bibliography tags which are used by the doxygen \cite command? Other than listing all the tags in the itk_dict.txt file.

So do you mean don't spell check the word after the "\cite" command? I'll have a look at it.

@zivy
Copy link
Member Author

zivy commented Jan 23, 2025

Yes. If there's the "\cite" directive ignore the next word which is the bibtex tag for the reference. Otherwise we'll have to add these exceptions for every reference because the tags are arbitrary and generally not "real" words. Thanks.

Another option is to use the bibtexparser package. The spellchecker will have bibliography files that it then parses and auto-magically adds the tags to the ignore list. This is more specific than ignore all words that appear after the "\cite" directive which is particular to doxygen and may not be the right thing to do in a different setting. Some relevant code:

import bibtexparser

bib_file = "my.bib"

with open(bib_file) as biblatex_file:
    bib_database = bibtexparser.load(biblatex_file)

for k in bib_database.get_entry_dict().keys():
    print(k)

@dzenanz
Copy link
Member

dzenanz commented Jan 23, 2025

Already great progress!

Copy link
Member

@jhlegarreta jhlegarreta left a comment

Choose a reason for hiding this comment

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

Looks great ❤️ 🚀. Thanks for doing this @zivy.

Two minor comments:

  • Remove the dot from the subject message.
  • Use the imperative mode.

Some comments that would require more work, as consistency would be important in this file:

  • Use the same style for names, e.g. First Name Last Name and etc.
  • Use brackets consistency for the field values. Use double brackets for all titles so that the cases are respected.
  • Do not add whitespaces, indentations or add them systematically and consistently.
  • Add first all articles, the books, then bookchapters, etc.: alphabetically.
  • Sort the entries alphabetically within each group.
  • Sort the field for each entry type the same way.
  • Define and document the keys, e.g. lastnameYYYY and how collisions are resolved in the ITK documentation.

I know this is a lot of work, but the earlier is done, the easier it is to do for the upcoming cases as it sets a clear example.

Have you used some tool to gather this, if yes, please describe it in the commit message.

Is it still a draft or is it ready to be merged according to you @zivy ?

@hjmjohnson
Copy link
Member

@zivy Very nice. Perhaps just bulk adding these citations to the itk dictionary would be the easiest.

@zivy zivy force-pushed the doxygenBib1 branch 3 times, most recently from a7d2e97 to 031beda Compare January 24, 2025 00:35
@zivy
Copy link
Member Author

zivy commented Jan 24, 2025

@jhlegarreta I modified the commit message per your request (first two points). I don't have a style preference and all the variations found in the bib file were obtained from the online source of each of the publications, so there is inherent variability. I think this is ready for merge, but it won't pass the spellchecking due to the use of bibtex tags.

Sadly this is a tedious manual process because the inline citations are free-form, sometimes incomplete and sometimes partially incorrect (detecting all of them by assuming the year will be listed so searching for what looks like a year in all *.h files).

@hjmjohnson Will do a bulk dictionary update if @dave3d doesn't add this functionality in the next couple of days.

For now I think this PR can be merged.

@jhlegarreta
Copy link
Member

@jhlegarreta I modified the commit message per your request (first two points). I don't have a style preference and all the variations found in the bib file were obtained from the online source of each of the publications, so there is inherent variability. I think this is ready for merge, but it won't pass the spellchecking due to the use of bibtex tags.

Sadly this is a tedious manual process because the inline citations are free-form, sometimes incomplete and sometimes partially incorrect (detecting all of them by assuming the year will be listed so searching for what looks like a year in all *.h files).

I know. I understand. Thanks for this work @zivy 💯.

@jhlegarreta
Copy link
Member

Sorry, closed inadvertently.

@jhlegarreta jhlegarreta reopened this Jan 24, 2025
@zivy
Copy link
Member Author

zivy commented Jan 24, 2025

@jhlegarreta It's been a long day. I am stepping away from the computer before I do more harm than good 😪

@zivy zivy force-pushed the doxygenBib1 branch 2 times, most recently from 3d8e263 to a251fe8 Compare January 26, 2025 17:40
@zivy
Copy link
Member Author

zivy commented Jan 26, 2025

Some additional updates:

  1. Per @albert-github's comment, populated the url field in the bibtex file using the doi information. This enables hyperlink creation using the default/current doxygen setup.
  2. Per @jhlegarreta comment above, used the bibtex-tidy tool, the bibliography file has a more consistent look-and-feel (even though this doesn't matter in terms of functionality). Not added as a pre-commit hook because it currently does not support a check only setup.

@jhlegarreta
Copy link
Member

Per @jhlegarreta comment above, used the bibtex-tidy tool, the bibliography file has a more consistent look-and-feel (even though this doesn't matter in terms of functionality). Not added as a pre-commit hook because it currently does not support a check only setup.

Simply great @zivy 💯. Thanks for doing that !

First PR out of N, converting raw inline citations with various styles to
using a bibliography database and the doxygen cite command.

Bibtex file was formatted using bibtex-tidy
(https://github.com/FlamingTempura/bibtex-tidy). This tool can be used
as a pre-commit hook but currently does not have an option for just
performing compliance checking so not added to .pre-commit-config.yaml
file.
@github-actions github-actions bot added the area:Python wrapping Python bindings for a class label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Documentation Issues affecting the Documentation module area:Filtering Issues affecting the Filtering module area:Python wrapping Python bindings for a class area:Registration Issues affecting the Registration module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants