ImperialCollegeLondon / R2T2

Research References Tracking Tool
MIT License
14 stars 155 forks source link

parse different formats of docstring / plain text references #40

Closed de-code closed 4 years ago

de-code commented 4 years ago

part of #15

this is adding support for the following formats:

sphinx:

:cite:`1987:nelson`

latex:

\cite{1987:nelson}

doxygen:

\cite 1987:nelson

For Sphinx and LaTex the references may be separated by a comma.

LaTex and Doxygen may have the issue of getting rejected by a linter (due to \c).

It is still not attempting to extract the purpose of the citation.

codecov[bot] commented 4 years ago

Codecov Report

Merging #40 into develop will increase coverage by 1.93%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #40      +/-   ##
===========================================
+ Coverage    72.19%   74.13%   +1.93%     
===========================================
  Files            8        8              
  Lines          241      259      +18     
===========================================
+ Hits           174      192      +18     
  Misses          67       67              
Impacted Files Coverage Δ
r2t2/plain_text_parser.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 656da9d...650733b. Read the comment docs.

de-code commented 4 years ago

Example:

$ python -m r2t2 --static --docstring examples/docstring_reference.py 
Referenced in: my_great_function
Source file: examples/docstring_reference.py
Line: 1
        [1] automatically parsed from docstring - https://doi.org/10.5281/zenodo.1185316

Referenced in: my_great_function_2
Source file: examples/docstring_reference.py
Line: 11
        [1] automatically parsed from docstring - 1987:nelson
valentinsulzer commented 4 years ago

Not related to this issue directly, but how come --docstring needs to be passed as an argument? Shouldn't the default settings also parse docstrings?

de-code commented 4 years ago

Not related to this issue directly, but how come --docstring needs to be passed as an argument? Shouldn't the default settings also parse docstrings?

Yes, I am not sure. I added it as a precaution. But it could certainly be made the default. I thought maybe it's good to get it tested more on real examples (in case it's causing more false positives).