Thread overview
clipboard button to copy selective import from documentation?
Jun 04, 2016
Martin Nowak
Jun 04, 2016
Seb
Jun 04, 2016
Vladimir Panteleev
Jun 05, 2016
Martin Nowak
Jun 05, 2016
Vladimir Panteleev
Jun 05, 2016
Vladimir Panteleev
Jun 05, 2016
Dicebot
June 04, 2016
I'm finding myself writing a lot of selective imports nowaday, while also browsing the documentation (sometimes even using dman).

I though it might be a nice to have a "copy-as-selective-import" button
next to the anchor link.
Then once you find what you've been looking for, e.g.
http://dlang.org/phobos/std_math.html#.approxEqual, you can click on it
and paste

    import std.math : approxEqual;

into your code (and edit it accordingly).

Useful? What do you think? Anyone volunteering?

-Martin

NB: We use clipboard.js on the dub registry, a JS only clipboard solution.
June 04, 2016
On Saturday, 4 June 2016 at 16:10:26 UTC, Martin Nowak wrote:
> I'm finding myself writing a lot of selective imports nowaday, while also browsing the documentation (sometimes even using dman).
>
> I though it might be a nice to have a "copy-as-selective-import" button
> next to the anchor link.
> Then once you find what you've been looking for, e.g.
> http://dlang.org/phobos/std_math.html#.approxEqual, you can click on it
> and paste
>
>     import std.math : approxEqual;
>
> into your code (and edit it accordingly).
>
> Useful? What do you think?

Yes.

> Anyone volunteering?

How about https://github.com/dlang/dlang.org/pull/1330?
June 04, 2016
On Saturday, 4 June 2016 at 16:10:26 UTC, Martin Nowak wrote:
> Useful? What do you think? Anyone volunteering?

Generally I'm not a fan of bloating things up with JavaScript widgets. Perhaps only if there is a lot of demand for this?

Perhaps we should improve editor support instead. For my previous editor I had this nice setup:

http://dump.thecybershadow.net/e91be687ebaeb0171d830025adf82848/autofix.gif

I've added a json target to the Phobos posix.mak a while ago. Care to beat me to writing the Emacs Lisp port? :)

DCD would also be one way of achieving this (one advantage of its current gobble-up-everything model).

June 05, 2016
On Saturday, 4 June 2016 at 18:21:27 UTC, Vladimir Panteleev wrote:
> Generally I'm not a fan of bloating things up with JavaScript widgets. Perhaps only if there is a lot of demand for this?

Bloat? One button per entity and a single js function?

> Perhaps we should improve editor support instead. For my previous editor I had this nice setup:
>
> http://dump.thecybershadow.net/e91be687ebaeb0171d830025adf82848/autofix.gif
>
> I've added a json target to the Phobos posix.mak a while ago. Care to beat me to writing the Emacs Lisp port? :)

Interesting, but relying on compile errors will increase debug/test turnaround times. It also doesn't quite fit my workflow which goes like this.

- wasn't there a function for that somewhere (searching, sometimes browsing to find the right function)
- reviewing documentation and examples (how to use)
- type `import std.algorithm.iteration : sum`

Do we have some website stats to know how people are using our documentation?
June 05, 2016
On Sunday, 5 June 2016 at 14:00:37 UTC, Martin Nowak wrote:
> On Saturday, 4 June 2016 at 18:21:27 UTC, Vladimir Panteleev wrote:
>> Generally I'm not a fan of bloating things up with JavaScript widgets. Perhaps only if there is a lot of demand for this?
>
> Bloat? One button per entity and a single js function?

Well, you did mention an additional JavaScript library, so that's one more dependency / request per cold cache. Also, if not bloat, then visual clutter.

I'm not against adding it if there's demand, but right now it does sound pretty specific. Have you seen this being done in other languages' standard libraries?

>> Perhaps we should improve editor support instead. For my previous editor I had this nice setup:
>>
>> http://dump.thecybershadow.net/e91be687ebaeb0171d830025adf82848/autofix.gif
>>
>> I've added a json target to the Phobos posix.mak a while ago. Care to beat me to writing the Emacs Lisp port? :)
>
> Interesting, but relying on compile errors will increase debug/test turnaround times. It also doesn't quite fit my workflow which goes like this.
>
> - wasn't there a function for that somewhere (searching, sometimes browsing to find the right function)
> - reviewing documentation and examples (how to use)
> - type `import std.algorithm.iteration : sum`

Well, use of selective imports seems subjective, though it does sound like good practice. The editor integration doesn't need to rely on compiler errors, e.g. DCD could just search its cache for all known modules known to declare the symbol-at-point. Another idea is a macro which transforms the URL to the symbol documentation into a selective import / fully qualified name.

> Do we have some website stats to know how people are using our documentation?

We do have statistics for server requests (i.e. browser usage), but nothing more, AFAIK. I'm not even sure what statistics we could gather that could infer the need (or lack) for such a feature.

June 05, 2016
On 6/5/16 10:10 AM, Vladimir Panteleev wrote:
> On Sunday, 5 June 2016 at 14:00:37 UTC, Martin Nowak wrote:
>> On Saturday, 4 June 2016 at 18:21:27 UTC, Vladimir Panteleev wrote:
>>> Generally I'm not a fan of bloating things up with JavaScript
>>> widgets. Perhaps only if there is a lot of demand for this?
>>
>> Bloat? One button per entity and a single js function?
>
> Well, you did mention an additional JavaScript library, so that's one
> more dependency / request per cold cache. Also, if not bloat, then
> visual clutter.
>
> I'm not against adding it if there's demand, but right now it does sound
> pretty specific. Have you seen this being done in other languages'
> standard libraries?

Why not add the information to do a selective import to a "more info" popup or so, and then anyone who wants to go the next step to have a button for the clipboard can have a client-side script.

-Steve
June 05, 2016
On Sunday, 5 June 2016 at 14:34:08 UTC, Steven Schveighoffer wrote:
> Why not add the information to do a selective import to a "more info" popup or so, and then anyone who wants to go the next step to have a button for the clipboard can have a client-side script.

That seems like a bizarre compromise. Then why not have the entire functionality as a client-side script?
June 05, 2016
On 6/5/16 10:35 AM, Vladimir Panteleev wrote:
> On Sunday, 5 June 2016 at 14:34:08 UTC, Steven Schveighoffer wrote:
>> Why not add the information to do a selective import to a "more info"
>> popup or so, and then anyone who wants to go the next step to have a
>> button for the clipboard can have a client-side script.
>
> That seems like a bizarre compromise. Then why not have the entire
> functionality as a client-side script?

As long as it's possible to make the client-side script solution given the current pages.

It also might be useful even without a javascript-to-clipboard button to be able to copy and paste the text yourself.

Don't know about you, but whenever I'm using github, I don't invent the command line to git clone, I just copy and paste whatever github tells me. I find that very useful.

-Steve
June 05, 2016
If I needed something like that, I'd probably do it as DCD/dsymbol based script instead so that it can work with any editor and any library (not just Phobos).