www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D source code formatter

reply psychoticRabbit <meagain meagain.com> writes:
I rely (heavily) on clang-format in my C code. It save me so much 
effort and has become a vital day to day tool for me.

I was wondering whether D also has a 'reliable' source code 
formatter.
(reliable being a key word there).

Also, if it does, then why is it not included in the distribution 
- given the importance of consistent source code formatting these 
days.
Feb 21 2018
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit 
wrote:
 I rely (heavily) on clang-format in my C code. It save me so 
 much effort and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code 
 formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the 
 distribution - given the importance of consistent source code 
 formatting these days.
look for 'dfmt'
Feb 21 2018
parent reply psychoticRabbit <meagain meagain.com> writes:
On Thursday, 22 February 2018 at 04:48:58 UTC, Nicholas Wilson 
wrote:
 On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit 
 wrote:
 I rely (heavily) on clang-format in my C code. It save me so 
 much effort and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code 
 formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the 
 distribution - given the importance of consistent source code 
 formatting these days.
look for 'dfmt'
thanks. but do you mean: dfmt is certainly reliable, so go look for it. or for look for dfmt and work out whether it's reliable.
Feb 21 2018
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 22/02/2018 6:38 PM, psychoticRabbit wrote:
 On Thursday, 22 February 2018 at 04:48:58 UTC, Nicholas Wilson wrote:
 On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit wrote:
 I rely (heavily) on clang-format in my C code. It save me so much 
 effort and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the distribution - 
 given the importance of consistent source code formatting these days.
look for 'dfmt'
thanks. but do you mean: dfmt is certainly reliable, so go look for it.  or for look for dfmt and work out whether it's reliable.
It's the only one we have as a separate tool. https://github.com/dlang-community/dfmt
Feb 21 2018
prev sibling parent aberba <karabutaworld gmail.com> writes:
On Thursday, 22 February 2018 at 05:38:38 UTC, psychoticRabbit 
wrote:
 On Thursday, 22 February 2018 at 04:48:58 UTC, Nicholas Wilson 
 wrote:
 On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit 
 wrote:
 I rely (heavily) on clang-format in my C code. It save me so 
 much effort and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code 
 formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the 
 distribution - given the importance of consistent source code 
 formatting these days.
look for 'dfmt'
thanks. but do you mean: dfmt is certainly reliable, so go look for it. or for look for dfmt and work out whether it's reliable.
dfmt is available along witj DCD and other D tools in Visual Studio Code. Its all package in the code-d package. dfmt formats D code good enough for the common cases as I don't do much CTFE or cryptic D coding style. VS Code is slow though. Its built with electron (html, css, Javascript) and uses a lot of cpu and ram.
Feb 21 2018
prev sibling parent reply Seb <seb wilzba.ch> writes:
On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit 
wrote:
 I rely (heavily) on clang-format in my C code. It save me so 
 much effort and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code 
 formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the 
 distribution - given the importance of consistent source code 
 formatting these days.
See https://github.com/dlang-community/dfmt/issues/249 for why it was never included in the release distribution. In short: Brian was never really interested in packaging and investing time into releasing his tools, so it stalled. Now that dub is part of the release distribution, it's simply: dub fetch dfmt dub run dfmt So there's essentially no big need to ship it in the release archives. Though Sociomantic has recently taken over the release process of dfmt and currently provides APT packages at bintray: https://bintray.com/dlang-community/apt/dfmt
Feb 21 2018
next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
note that we'd need to implement
https://github.com/dlang-community/dfmt/issues/159 (
option to format only diff-ed lines (like git clang-format))
in order to run dfmt on only the part of source code that was modified in a PR.

this is  to avoid concern that it affects git history  / git blame
(although these can skip blacklisted format-only commits or skip
white-space diffs)

On Wed, Feb 21, 2018 at 11:00 PM, Seb via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Thursday, 22 February 2018 at 04:35:24 UTC, psychoticRabbit wrote:
 I rely (heavily) on clang-format in my C code. It save me so much effort
 and has become a vital day to day tool for me.

 I was wondering whether D also has a 'reliable' source code formatter.
 (reliable being a key word there).

 Also, if it does, then why is it not included in the distribution - given
 the importance of consistent source code formatting these days.
See https://github.com/dlang-community/dfmt/issues/249 for why it was never included in the release distribution. In short: Brian was never really interested in packaging and investing time into releasing his tools, so it stalled. Now that dub is part of the release distribution, it's simply: dub fetch dfmt dub run dfmt So there's essentially no big need to ship it in the release archives. Though Sociomantic has recently taken over the release process of dfmt and currently provides APT packages at bintray: https://bintray.com/dlang-community/apt/dfmt
Feb 21 2018
prev sibling parent Russel Winder <russel winder.org.uk> writes:
On Thu, 2018-02-22 at 07:00 +0000, Seb via Digitalmars-d wrote:
 [=E2=80=A6]
 Though Sociomantic has recently taken over the release process of=20
 dfmt and currently provides APT packages at bintray:
=20
 https://bintray.com/dlang-community/apt/dfmt
So now we have both: http://d-apt.sourceforge.net/ and=20 https://bintray.com/dlang-community/apt Is now the time to discuss harmonising Debian support especially since there is a whole slew of stuff getting into the main Debian archive due to the efforts of the Debian D Language Group: pkg-d-devel lists.alioth.debian.org --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
Feb 22 2018