azu / gitbook-plugin-include-codeblock

GitBook plugin for including file
Other
40 stars 25 forks source link

Add snippet feature #12

Closed gdolle closed 8 years ago

gdolle commented 8 years ago

Add snippet code feature similarly to doxygen ability. See also the doxygen document guide for comment style.

Example:

We consider the following C++ code,

// test.cpp
#include <iostream>
/** [marker0] */
int main()
{
   //! [marker1]
   int a=0;
   //! [marker1]
   /// [marker2]
   int b=1;
   int c=2;
   /// [marker2]
   return 0;
}
/** [marker0] */

then both slice can be imported via

   int a=0;
   int b=1;
   int c=2;
int main()
{
   int a=0;
   int b=1;
   int c=2;
   return 0;
}

and does not depend on lines number in that case.

NB: C/C++, latex, python supported for now but could be improved.

prudhomm commented 8 years ago

very nice !

azu commented 8 years ago

@gdolle Thanks for nice feature!

Summary after I've reviewed.

prudhomm commented 8 years ago

@gdolle @azu it would be nice to have an option to actually remove the // [marker1] lines from being included so that we have a nice clean code example.

consider a code that has all the markers, we go through all of them to explain the code (we don't show the markers). and then at the end we want to put the entire code. it would not be very nice to have all these // [marker] and there should be a flag to automatically remove them (enabled by default I would say).

gdolle commented 8 years ago

@azu @prudhomm I updated following the review comments, meaning:

Note that I updated espower-babel which is deprecated now. (Test pass see travis. ;) )

azu commented 8 years ago

@gdolle Thanks for great work! I've merged it and publish 1.8.0.

azu commented 8 years ago

After merging, I found a breaking backward compatibily. I've opened pull request to fix that issue #13

azu commented 8 years ago

I've fixed regression issue #13 and publish 1.8.1.

Thanks again @gdolle @prudhomm