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

insert back-reference as comment to the .R source files used in each generated file #291

Merged
merged 3 commits into from Oct 8, 2014
Merged

insert back-reference as comment to the .R source files used in each generated file #291

merged 3 commits into from Oct 8, 2014

Conversation

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Oct 8, 2014

Proof-of-concept implementation, uses a new tag type "backref" to record the value of "srcref" at the time the title is parsed.

I'm not sure if this collects all back references, but surely it should collect the file where the title is defined, and which is probably the one the user wants to look at first.

Still open:

  • Tests
  • Usage tests
  • Prepend file names with R/
  • NEWS bullet

Fixes #290.

@krlmlr krlmlr changed the title insert back-reference to the .R source files used in each comment insert back-reference as comment to the .R source files used in each generated file Oct 8, 2014
@@ -233,7 +233,8 @@ process_description <- function(partitum, base_path) {
details <- NULL
}

c(new_tag("title", title),
c(new_tag("backref", basename(partitum$srcref$filename)),
Copy link
Member

@hadley hadley Oct 8, 2014

Choose a reason for hiding this comment

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

This doesn't seem like the right place to me - I think near the top of roclet_rd_one would make more sense. Maybe right after where name is initialised?

@hadley
Copy link
Member

@hadley hadley commented Oct 8, 2014

Happy to be proved wrong :)

@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented Oct 8, 2014

Thanks for the review and the heads-up. I think this is now good for a second review.

@@ -52,6 +52,7 @@ S3method(format,section_tag)
S3method(format,seealso_tag)
S3method(format,slot_tag)
S3method(format,source_tag)
S3method(format,srcref_comment_tag)
Copy link
Member

@hadley hadley Oct 8, 2014

Choose a reason for hiding this comment

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

Why not just srcref_tag?

Copy link
Member Author

@krlmlr krlmlr Oct 8, 2014

Choose a reason for hiding this comment

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

It's a "special" tag, different from others, as it will be rendered as a comment. I'll change it anyway.

@hadley
Copy link
Member

@hadley hadley commented Oct 8, 2014

Thanks! Would you mind squashing?

Kirill Müller added 3 commits Oct 8, 2014
…comment

- prepend R/ to file names
- use srcref as tag name
- supply test
@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented Oct 8, 2014

Done.

hadley added a commit that referenced this issue Oct 8, 2014
insert back-reference as comment to the .R source files used in each generated file
@hadley hadley merged commit 7e251ed into r-lib:master Oct 8, 2014
1 check passed
@hadley
Copy link
Member

@hadley hadley commented Oct 8, 2014

Thanks!

@krlmlr krlmlr deleted the 290-source-comment branch Oct 8, 2014
@hadley
Copy link
Member

@hadley hadley commented Oct 9, 2014

Thinking on it more - it would be useful to also have an explicit @backref tag. Then systems like Rcpp could use it to point you back to the original source location.

@krlmlr krlmlr mentioned this pull request Oct 10, 2014
@tbates
Copy link
Contributor

@tbates tbates commented Nov 9, 2014

This is great to see!

yihui added a commit to yihui/knitr that referenced this issue Dec 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants