July 05, 2012
On 2012-07-05 06:46, Walter Bright wrote:
> It would be nice to have a D source code formatter. But it needs a
> champion. Who's up for it?

It's a great idea but as others have said, I see no point in creating this until we have a D compiler available as a library.

-- 
/Jacob Carlborg


July 05, 2012
On 2012-07-05 06:46, Walter Bright wrote:
> It would be nice to have a D source code formatter. But it needs a
> champion. Who's up for it?

I just tried ddmd-clean and it already does some form of source code formatting. It will format the following file:

https://github.com/zachthemystic/ddmd-clean/blob/master/main.d

To something like this:

http://pastebin.com/JUauQDvb

https://github.com/zachthemystic/ddmd-clean

-- 
/Jacob Carlborg


July 05, 2012
On Thursday, 5 July 2012 at 04:47:29 UTC, Walter Bright wrote:
> It would be nice to have a D source code formatter. But it needs a champion. Who's up for it?

I'm already working on adding formatting to my general-purpose D tool.

https://github.com/Hackerpilot/Dscanner
July 05, 2012
On 7/4/2012 9:46 PM, Walter Bright wrote:
> It would be nice to have a D source code formatter. But it needs a champion.
> Who's up for it?

I think that formatting the code is actually rather easy - the hard part will be dealing with the comments in a reasonable way.

July 05, 2012
On Thursday, 5 July 2012 at 19:22:56 UTC, Walter Bright wrote:
> I think that formatting the code is actually rather easy - the hard part will be dealing with the comments in a reasonable way.

Eclipse has had a LOT of time and energy put into it, and it still makes my javadoc uglier than it was before formatting.

My thought is to properly indent/align comments, but other than that leave them unmodified. There are too many things that can go wrong with re-wrapping them (I'm imagining accidentally ruining somebody's carefully-crafted ASCII art diagram).


July 05, 2012
On 7/5/2012 1:52 PM, Brian Schott wrote:
> On Thursday, 5 July 2012 at 19:22:56 UTC, Walter Bright wrote:
>> I think that formatting the code is actually rather easy - the hard part will
>> be dealing with the comments in a reasonable way.
>
> Eclipse has had a LOT of time and energy put into it, and it still makes my
> javadoc uglier than it was before formatting.
>
> My thought is to properly indent/align comments, but other than that leave them
> unmodified. There are too many things that can go wrong with re-wrapping them
> (I'm imagining accidentally ruining somebody's carefully-crafted ASCII art
> diagram).
>
>

I agree that whatever is inside the comment should be left alone. I was more talking about lining up comment blocks, etc.

July 05, 2012
On Thursday, 5 July 2012 at 22:25:15 UTC, Walter Bright wrote:
> I agree that whatever is inside the comment should be left alone. I was more talking about lining up comment blocks, etc.
Why would that be more difficult to do than code formatting? I'm wondering.

July 05, 2012
On Thursday, 5 July 2012 at 22:27:09 UTC, Roman D. Boiko wrote:
> On Thursday, 5 July 2012 at 22:25:15 UTC, Walter Bright wrote:
>> I agree that whatever is inside the comment should be left alone. I was more talking about lining up comment blocks, etc.
> Why would that be more difficult to do than code formatting? I'm wondering.

If the forum interface strips leading whitespace, this message will look pointless.

/**
 * This is easy
 */

// trivial
// multi-line
// comment

/* This is a list where indenting is significant:
    * list item
    * other list item
    * How do we indent this?
*/

/* I want this to be fixed
  * because these lines are off by one space
* and should be aligned
*/

    /++ Ddoc is, IIRC, bad at handling leading spaces in code samples
---
foo("hello world");
---
     +/
    void foo(string arg) {
July 15, 2012
On Thursday, 5 July 2012 at 10:27:41 UTC, maarten van damme wrote:
> I'm using uncrustify too although it has the annoying habbit of
> rewriting => to = > causing all functions using the new lambda syntax
> to break.

Creating a formatter that works *well* is a larger challenge than I first imagined, so I took a small break and fixed that bug in uncrustify. The pull request is here: https://github.com/bengardner/uncrustify/pull/86


1 2
Next ›   Last »