Skip to content

Commit

Permalink
Minor feature enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-lehn committed Mar 11, 2014
1 parent 85a31d9 commit 3eb26b5
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 33 deletions.
19 changes: 11 additions & 8 deletions CxxTools/Makefile
@@ -1,10 +1,5 @@
CXX = clang++
CXX = clang++-3.2
CXXFLAGS += -std=c++11 -Wall -Werror
LDFLAGS += -lclang

SOURCE_FILES = $(wildcard *.cc)
OBJECT_FILES = $(patsubst %.cc,%.o,$(SOURCE_FILES))
TARGETS = $(patsubst %.cc,%,$(SOURCE_FILES))

#
# Adjust CPPFLAGS and LDFLAGS for libclang
Expand All @@ -15,8 +10,16 @@ TARGETS = $(patsubst %.cc,%,$(SOURCE_FILES))
# LDFLAGS += -L /opt/local/libexec/llvm-3.2/lib

# When using libclang built by (home)brew
CPPFLAGS += -I/usr/local/opt/llvm/include
LDFLAGS += -L/usr/local/opt/llvm/lib
CPPFLAGS += -I/usr/local/opt/llvm32/lib/llvm-3.2/include
LDFLAGS += -L/usr/local/opt/llvm32/lib/llvm-3.2/lib

#

SOURCE_FILES = $(wildcard *.cc)
OBJECT_FILES = $(patsubst %.cc,%.o,$(SOURCE_FILES))
TARGETS = $(patsubst %.cc,%,$(SOURCE_FILES))

LDFLAGS += -lclang

all : $(TARGETS)

Expand Down
2 changes: 1 addition & 1 deletion Executables/doctool
Expand Up @@ -44,7 +44,7 @@ use CxxIndex;

my $DocTool__convertSourcefiles = 1;
my $DocTool__createCrossReferences;
my $DocTool__force = 1;
my $DocTool__force;
my $DocTool__parseOnly;
my $DocTool__updateCxxIndex;
my $DocTool__createLatexPics;
Expand Down
44 changes: 36 additions & 8 deletions Library/Components/code.pm
Expand Up @@ -19,18 +19,34 @@ sub new
optionString => "",
options => undef,
html => undef,
type => "cc",
linenumbers => 0,
type => undef,
@_};
bless ($self, $class);

# handle options
$self->{options} = {file => "",
create => 1,
downloadable => 1,
type => $self->{type},
type => undef,
linenumbers => undef,
plain => undef,
Options->Split(string => $self->{optionString})};

if ($self->{options}->{title}) {
if ($self->{options}->{title} eq "no") {
$self->{options}->{notitle} = 1
}
}

if ($self->{options}->{file} && (!$self->{options}->{type})) {
if ($self->{options}->{file} =~ /\.(.*)$/) {
$self->{options}->{type} = $1;
}
}
if (!$self->{options}->{type}) {
$self->{options}->{type} = "cc"; # default to C++
}

if (($self->{options}->{file}) && ($self->{options}->{downloadable})) {
my $filename = join("/", $ENV{DOWNLOAD_DIR}, $self->{options}->{file});
DocUtils->SaveLinebuffer(file => $filename,
Expand Down Expand Up @@ -69,12 +85,24 @@ sub convert
my %args = (html => undef,
@_);

my @codelines = Convert->CodeBlock(codelinesRef => $self->{lines},
fileExtension => $self->{options}->{type},
linenumbers => $self->{linenumbers});
my @codelines;

if (! $self->{options}->{plain}) {
@codelines = Convert->CodeBlock(
codelinesRef => $self->{lines},
fileExtension => $self->{options}->{type},
linenumbers => $self->{options}->{linenumbers});
} else {
@codelines = @{$self->{lines}};
}

$args{html}->addLine(line => "<div class=\"code\">\n");
if ($self->{options}->{file}) {
if (! $self->{options}->{class}) {
$args{html}->addLine(line => "<div class=\"code\">\n");
} else {
my $class = $self->{options}->{class};
$args{html}->addLine(line => "<div class=\"$class\">\n");
}
if ($self->{options}->{file} and !$self->{options}->{notitle}) {
$args{html}->addLine(line => "<div class=\"code_title\">\n");
my $sourcePath = $args{html}->{docEnv}->{sourcePath};
my $file = $self->{options}->{file};
Expand Down
48 changes: 35 additions & 13 deletions Library/Components/import.pm
Expand Up @@ -10,6 +10,7 @@ sub MakeCodeBlock
my %args = (code => undef,
file => undef,
create => 0,
optionString => undef,
@_);

my @lines = @{$args{code}};
Expand All @@ -18,7 +19,11 @@ sub MakeCodeBlock
if (scalar(@lines)>0) {
my $code = "CODE";
if ($args{file}) {
$code = $code . " (file=$args{file}, create=$args{create})";
$code = $code . " (file=$args{file}, create=$args{create}";
if ($args{optionString}) {
$code = $code . ", " . $args{optionString};
}
$code = $code . ")";
}
unshift(@lines, "___ $code ___");

Expand All @@ -35,6 +40,7 @@ sub ExpandBriefComments
{
my $class = shift;
my %args = (input => undef,
optionString => undef,
@_);

my @input = @{$args{input}};
Expand Down Expand Up @@ -66,19 +72,24 @@ sub ExpandBriefComments
while ($i<=$#input) {
$line = $input[$i];
if (($line =~ /^\s*$/) || ($line =~ /^\s*$Import::Comment-.*$/)) {
push(@output, Import->MakeCodeBlock(code => \@codeLines));
push(@output, Import->MakeCodeBlock(
code => \@codeLines,
optionString => $args{optionString}));
last;
}
if ($line =~ /^\s*$Import::Comment.*$/) {
push(@output, Import->MakeCodeBlock(code => \@codeLines));
push(@output, Import->MakeCodeBlock(
code => \@codeLines,
optionString => $args{optionString}));
--$i;
last;
}
push(@codeLines, $line);
++$i;
}
}
push(@output, Import->MakeCodeBlock(code => \@codeLines));
push(@output, Import->MakeCodeBlock(code => \@codeLines,
optionString => $args{optionString}));
return @output;
}

Expand All @@ -87,6 +98,7 @@ sub ExpandComments
{
my $class = shift;
my %args = (input => undef,
optionString => undef,
@_);

my @input = @{$args{input}};
Expand All @@ -97,7 +109,9 @@ sub ExpandComments
my $line = $input[$i];

if ($line =~ s/^\s*$Import::Comment(.*)$//) {
push(@output, Import->MakeCodeBlock(code => \@codeLines));
push(@output, Import->MakeCodeBlock(
code => \@codeLines,
optionString => $args{optionString}));
push(@output, $1);
next;
}
Expand All @@ -112,7 +126,8 @@ sub ExpandComments
}
}
}
push(@output, Import->MakeCodeBlock(code => \@codeLines));
push(@output, Import->MakeCodeBlock(code => \@codeLines,
optionString => $args{optionString}));
return @output;
}

Expand All @@ -122,6 +137,7 @@ sub RemoveComments
my %args = (input => undef,
file => undef,
create => 0,
optionString => undef,
@_);

my @input = @{$args{input}};
Expand Down Expand Up @@ -170,16 +186,22 @@ sub Parse
my @output;

if ($option{brief}) {
@output = Import->ExpandBriefComments(input => \@input);
@output = Import->ExpandBriefComments(
input => \@input,
optionString => $args{optionString});
} else {
if ($option{stripped}) {
@output = Import->RemoveComments(input => \@input,
file => $args{file},
create => $args{create});
@output = Import->RemoveComments(
input => \@input,
file => $args{file},
create => $args{create},
optionString => $args{optionString});
} else {
@output = Import->MakeCodeBlock(code => \@input,
file => $args{file},
create => $args{create});
@output = Import->MakeCodeBlock(
code => \@input,
file => $args{file},
create => $args{create},
optionString => $args{optionString});
}
}

Expand Down
11 changes: 10 additions & 1 deletion Library/Components/shell.pm
Expand Up @@ -27,6 +27,11 @@ sub new

die unless $self->{docEnv};

# handle options
$self->{options} = {hide => undef,
Options->Split(string => $self->{optionString})};


# remove empty lines
# concat lines that end on "+++"
my @lines;
Expand All @@ -47,6 +52,7 @@ sub new
}
}
$self->{lines} = \@lines;
$self->execute();

return $self;
}
Expand All @@ -59,7 +65,10 @@ sub html

die unless $args{html};

$self->execute();
if ($self->{options}->{hide}) {
return;
}

#$self->convert();
for my $line (@{$self->{html}}) {
$args{html}->addLine(line => $line, preserveIndent => 1);
Expand Down

0 comments on commit 3eb26b5

Please sign in to comment.