September 15, 2016
On 09/15/2016 10:15 AM, Adam D. Ruppe wrote:
> On Thursday, 15 September 2016 at 13:12:05 UTC, Manu wrote:
>> What does that mean? What's your process to produce this output?
>
> ./adrdox test.d
>
> The program internally runs pipeProcess over to latex to make the image
> when it sees the $(MATH ....) syntax.
>
>> Problem is, phobos uses vanilla ddoc... so we need that to do
>> everything we need.
>
> Yeah, that's why I forked phobos for my doc project too. Vanilla ddoc is
> a dead end.

Wait, but I just showed how with vanilla ddoc you can immediately use mathjax to do better than adrdox. No need for any pre/postprocessing or scripting, just one line of import. Could you please respond to that? -- Andrei
September 15, 2016
On 09/15/2016 10:37 AM, Johan Engelen wrote:
> On Thursday, 15 September 2016 at 11:39:13 UTC, Andrei Alexandrescu wrote:
>>
>> * ddoc has absolutely nada notion of rendering. To ask "how do I
>> render sqrt and aligned matrices with ddoc" does not compute. Is there
>> agreement on that?
>
> D has absolutely no notion of "databases", but I think it's fair to ask
> "how do I retrieve data from a database using D".

D is a language. Ddoc is a macro system. How could this simile possibly convey any information?

> DDoc bare does not need a notion of rendering, but the base system in
> place (call it the DDoc std lib) does need to present a way for a user
> to end up with a math equation "rendered" well.

No, sorry Johan this is a hopeless misunderstanding. Ddoc does not render absolutely anything. All it can do is output UTF text! We need to clear this up before continuing.


Andrei
September 15, 2016
On 09/15/2016 10:37 AM, Johan Engelen wrote:
>
> Well, I'm pretty sure just typing \( \) and running `dmd -D` is not
> going to give me the output that I want. Indeed it doesn't.
>
> But, as you write, it's easy to make it happen. Full example:
> ```
> /**
> * Macros:
> * DDOC =
> * <!DOCTYPE html>
> * <html lang="en-US">
> * <head>
> * <script type="text/javascript" async
> src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
>
> * </script>
> * <title>$(TITLE)</title>
> * </head>
> * <body><h1>$(TITLE)</h1>$(BODY)</body>
> * </html>
> */
>
> /**
> * \[
> *  \mathbf{V}_1 \times \mathbf{V}_2 =
> *   \begin{vmatrix}
> *    \mathbf{i} & \mathbf{j} & \mathbf{k} \\
> *    \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
> *    \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\
> *   \end{vmatrix}
> * \]
> */
>
> module ddoctest;
> ```
>
> `dmd ddoctest.d -D -o-` produces an HTML file with nice looking math in it.
>
> Now, can we please add this question to stackoverflow, and add this as
> an answer?
> :)

Probably a wiki page would be an awesome idea. -- Andrei

September 15, 2016
On Thursday, 15 September 2016 at 14:43:56 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 10:37 AM, Johan Engelen wrote:
>>
>> Now, can we please add this question to stackoverflow, and add this as
>> an answer?
>> :)
>
> Probably a wiki page would be an awesome idea. -- Andrei

We need more stackoverflow stuff. The voting system is awesome to get an answer to straightforward questions in a split second.

https://stackoverflow.com/questions/39514027/how-to-show-math-equations-with-ddoc


September 15, 2016
On Thursday, September 15, 2016 10:43:56 Andrei Alexandrescu via Digitalmars-d wrote:
> Probably a wiki page would be an awesome idea. -- Andrei

Well, for better or worse, he asked it on SO:

http://stackoverflow.com/questions/39514027/how-to-show-math-equations-with-ddoc

September 15, 2016
On Thursday, 15 September 2016 at 13:48:44 UTC, Andrei Alexandrescu wrote:
> That strikes me as an inferior solution to what's available today, which is used at http://erdani.com/d/DIP1000-typing-baseline.html.

But how did you do that? I think KaTeX may be a better solution for documentation because MathJax can be slow to render. It's basically MathJax modified for speed by Khan Academy.

https://github.com/Khan/KaTeX
September 15, 2016
On Thursday, 15 September 2016 at 14:42:37 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 10:37 AM, Johan Engelen wrote:
>> On Thursday, 15 September 2016 at 11:39:13 UTC, Andrei Alexandrescu wrote:
>>>
>>> * ddoc has absolutely nada notion of rendering. To ask "how do I
>>> render sqrt and aligned matrices with ddoc" does not compute. Is there
>>> agreement on that?
>>
>> D has absolutely no notion of "databases", but I think it's fair to ask
>> "how do I retrieve data from a database using D".
>
> D is a language. Ddoc is a macro system. How could this simile possibly convey any information?

Tool has absolutely nada notion of Thing. To ask "how do I do Thing with Tool", can still be an OK question (listener willing) to which there is a simple answer that you yourself have given here (thanks!!). Let's stop here? ;)
Btw, Ddoc is perhaps a little more than a macro system, and that's why using parameter names in equations is broken. Parameter names are replaced by (wait for it) a macro, so disabling that macro "fixes" the issue. See the stackoverflow example.
http://stackoverflow.com/a/39514239/3215806

>> DDoc bare does not need a notion of rendering, but the base system in
>> place (call it the DDoc std lib) does need to present a way for a user
>> to end up with a math equation "rendered" well.
>
> No, sorry Johan this is a hopeless misunderstanding. Ddoc does not render absolutely anything. All it can do is output UTF text! We need to clear this up before continuing.

I know that DDoc (currently) is just outputting a text file. I wrote "end up with...".
Please zoom out a little, read between the lines; I think most here write messages  without spelling out everything in exact mathematical detail. ;)
So indeed, the DDoc system does provide a simple way to end up with nice-looking equations: "import" MathJax, and just write \(...\). Excellent.

- Is there a way to "import" MathJax without having to redefine the DDOC macro?(seems a little brittle)

- Perhaps we can "standardize" the MathJax thing for Phobos docs? Would be nice for Manu's color lib and for Mir too. (where are the Mir guys anyway in this discussion? ;)

- Also, how about that parameter name problem? Any good fix for that?

September 15, 2016
On Thursday, 15 September 2016 at 15:43:39 UTC, Johan Engelen wrote:

> - Perhaps we can "standardize" the MathJax thing for Phobos docs? Would be nice for Manu's color lib and for Mir too. (where are the Mir guys anyway in this discussion? ;)

As I commented above to Andrei, I think KaTeX is better for documentation, because MathJax can be slow. KaTeX is basically MathJax that has been modified to be faster.

https://github.com/Khan/KaTeX
September 15, 2016
On 09/15/2016 11:13 AM, bachmeier wrote:
> On Thursday, 15 September 2016 at 13:48:44 UTC, Andrei Alexandrescu wrote:
>> That strikes me as an inferior solution to what's available today,
>> which is used at http://erdani.com/d/DIP1000-typing-baseline.html.
>
> But how did you do that?

See source at http://pasted.co/7ea68163 and Johan's example on SO.

It's imperfect: you need to define the entire DDOC macro, which is a bit goofy because that has a bunch of other things. We need to devise a better way in the long run.

> I think KaTeX may be a better solution for
> documentation because MathJax can be slow to render. It's basically
> MathJax modified for speed by Khan Academy.
>
> https://github.com/Khan/KaTeX

Even better!


Andrei
September 15, 2016
On 09/15/2016 05:43 PM, Johan Engelen wrote:
> - Perhaps we can "standardize" the MathJax thing for Phobos docs? Would
> be nice for Manu's color lib and for Mir too. (where are the Mir guys
> anyway in this discussion? ;)

I'm not familiar with MathJax. Looks like a client-side library. In my opinion that's not good enough. The work should be done during the build process, not in the browser. But maybe MathJax can be used that way?

> - Also, how about that parameter name problem? Any good fix for that?

Unless we're willing to get rid of auto-highlighting everywhere, the usual underscore prefixing will probably have to do.

Example:
----
/**
p <- highlighted
_p <- not highlighted, no underscore in output
*/
void f(int p) {}
----