RunestoneComponents icon indicating copy to clipboard operation
RunestoneComponents copied to clipboard

Updating codelens components to support Java and C++ in textbook.

Open escalerapadronl opened this issue 5 years ago • 5 comments

I am currently working on trying to update the codelens component so that Java and C++ code in the books have a "Show CodeLens" button and someone is able to traverse through the code line by line.

escalerapadronl avatar Nov 25 '19 15:11 escalerapadronl

I have narrowed it down to the button being created with the conditional found on line 261 in activecode.js:

if ($(this.origElem).data("codelens") && ! this.graderactive) {
        butt = document.createElement("button");
        $(butt).addClass("ac_opt btn btn-default");
        $(butt).text($.i18n("msg_activecode_show_codelens"));
        $(butt).css("margin-left", "10px");
        this.clButton = butt;
        ctrlDiv.appendChild(butt);
        $(butt).click(this.showCodelens.bind(this));
    } 

and deciding whether the code should have (this.origElem).data("codelens") with the conditional on line 303 in activecode.py :

  if "nocodelens" in self.options or self.options["language"] != "python":
            self.options["codelens"] = ""
        else:
            self.options["codelens"] = 'data-codelens="true"'

escalerapadronl avatar Nov 25 '19 16:11 escalerapadronl

I am not quite sure how these two work together to decide whether the activecode gets a "Show CodeLens" button or not.

escalerapadronl avatar Nov 25 '19 16:11 escalerapadronl

image I have attached a snippet of code that we changed so that it takes C++ and Java, but still no dice. Also attached, the error code that we get.

grrdsoto avatar Nov 25 '19 19:11 grrdsoto

image

grrdsoto avatar Nov 25 '19 19:11 grrdsoto

In my activecode.py around line 198 I have:

            "language": directives.unchanged,

It looks to me like you may have changed that to directives.flag? Unchanged does not put any restrictions on what the argument to the option can be. But directives.flag does not allow arguments which is what the error message is saying.

bnmnetp avatar Nov 25 '19 19:11 bnmnetp