Skip to content

Commit 8a298e7

Browse files
committed
asciidoc docs rendering
1 parent 25f474d commit 8a298e7

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

conanfile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,27 @@ class EnumFlagsConan(b2.B2.Mixin, ConanFile):
2929
url = "https://github.com/grisumbras/enum-flags"
3030
homepage = url
3131

32+
options = {"with_docs": [False, True]}
33+
default_options = {"with_docs": False}
34+
3235
exports_sources = (
3336
"jamroot.jam",
3437
"*build.jam",
3538
"exports/*.jam",
3639
"*.hpp",
3740
"*.cpp",
3841
"LICENSE*",
42+
"*.adoc",
3943
)
4044
no_copy_source = True
4145
build_requires = "boost_build/[>=1.68]@bincrafters/stable"
4246

47+
def b2_setup_builder(self, builder):
48+
if self.options.with_docs:
49+
builder.options.with_docs = True
50+
builder.using("asciidoctor")
51+
return builder
52+
4353
def package_info(self):
4454
self.info.header_only()
4555

doc/build.jam

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import asciidoctor ;
2+
import path ;
3+
4+
5+
project enum-flags-doc ;
6+
7+
path-constant HERE : . ;
8+
9+
10+
local rule templates-dir ( path ) {
11+
path = [ path.root $(path) $(HERE) ] ;
12+
local files = [ glob $(path)/* ] ;
13+
return <flags>"-T $(path)" <dependency>$(files) ;
14+
}
15+
16+
17+
alias common-attributes
18+
: usage-requirements
19+
<asciidoctor-attribute>nofooter
20+
<asciidoctor-attribute>source-highlighter=pygments
21+
<asciidoctor-attribute>pygments-linenums-mode=inline
22+
# <asciidoctor-attribute>pygments-css
23+
24+
# <asciidoctor-attribute>pygments-style=monokai
25+
<asciidoctor-attribute>pygments-style=paraiso-dark
26+
27+
# <asciidoctor-attribute>pygments-style=friendly
28+
29+
<asciidoctor-attribute>icons=font
30+
# <asciidoctor-attribute>stylesdir=styles
31+
32+
[ templates-dir templates ]
33+
;
34+
35+
36+
html index : index.adoc common-attributes ;

doc/examples/example0.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <flags/flags.hpp>
2+
3+
enum class MyEnum { Value1 = 1 , Value2 = 2 };
4+
ALLOW_FLAGS_FOR_ENUM(MyEnum)
5+
6+
int main() {
7+
auto mask = MyEnum::Value1 | MyEnum::Value2;
8+
if (mask & MyEnum::Value2) {
9+
// do something
10+
}
11+
return 0;
12+
}

doc/index.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
= enum-flags
2+
3+
*enum-flags* is a C++ library that allows you to convert scoped enums into bit
4+
flags. +
5+
You can use it as simple as this:
6+
7+
[source, c++]
8+
----
9+
include::examples/example0.cpp[]
10+
----
11+
12+
== Documentation
13+
14+
* *link:overview/index.html[Overview]* +
15+
An overview of the features and the design.
16+
17+
* *link:tutorial/index.html[Tutorial]* +
18+
A tutorial that shows how to use the library.
19+
20+
* *link:reference/index.html[Reference]* +
21+
API reference.

jamroot.jam

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import option ;
12
import package ;
23
import path ;
34

@@ -20,5 +21,7 @@ explicit headers ;
2021

2122
package.install-data license : enum-flags : LICENSE ;
2223

24+
if [ option.get with-docs : : yes ] { build-project doc ; }
25+
2326
alias install : headers license exports//install ;
2427
explicit install headers license ;

0 commit comments

Comments
 (0)