Skip to content

Commit

Permalink
Release 2.7.0 (#351)
Browse files Browse the repository at this point in the history
* Enhancement to support Unix path! (#344)

I'm not sure you already got a try or a feedback about it but actually pickles run relatively well under Linux with mono which is interesting when like me you can't get a windows machine.

However without this little change we can't get the folder structure display correctly.

Could you integrate this modification?

Thanks

* Release 2.6.3 (#348)

* Version Bump

* Update change log

* Add --enableComments Flag to Command Line - Default to True (#346)

* Command-Line Flag --comments - Default to True - Incl Unit Test

* Changed Command Line Argument --comments to --enableComments

* Added Enable Comments Option to MSBuild - Powershell - WPF Runners

* Fixed Bug with enableComments Property Not Being Used in MainViewModel

* Add EnableComments to the targets file

* Adapt change log

* Version bump to 2.7.0
  • Loading branch information
dirkrombauts authored Jun 14, 2016
1 parent 1d25afe commit 4d2ff43
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Features in Experimental are subject to change and removal without being conside

This document is formatted according to the principles of [Keep A CHANGELOG](http://keepachangelog.com).

## [2.7.0] - 2016-06-14

### Added

- Make #-style comments configurable - Default to True ([346](https://github.com/picklesdoc/pickles/issues/346)) (by [@ocsurfnut](https://github.com/ocsurfnut)).

## [2.6.3] - 2016-05-24

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set "picklesVersion=2.6.3"
set "picklesVersion=2.7.0"

cls

Expand Down
2 changes: 1 addition & 1 deletion src/Pickles/.vs/config/applicationhost.config
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</site>
<site name="Pickles.BaseDhtmlFiles" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Dev\Code\GitHub\DirkRombauts\Pickles\src\Pickles\Pickles.BaseDhtmlFiles" />
<virtualDirectory path="/" physicalPath="C:\src\pickles\src\Pickles\Pickles.BaseDhtmlFiles" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:52000:localhost" />
Expand Down
12 changes: 12 additions & 0 deletions src/Pickles/Pickles.MSBuild/Pickles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class Pickles : Task

public string IncludeExperimentalFeatures { get; set; }

public string EnableComments { get; set; }

public override bool Execute()
{
try
Expand Down Expand Up @@ -121,6 +123,16 @@ private void CaptureConfiguration(IConfiguration configuration, IFileSystem file
configuration.EnableExperimentalFeatures();
}
}

bool shouldEnableComments;

if (bool.TryParse(this.EnableComments, out shouldEnableComments))
{
if (!shouldEnableComments)
{
configuration.DisableComments();
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/Pickles/Pickles.MSBuild/build/Pickles.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SystemUnderTestVersion="$(Pickles_SystemUnderTestVersion)"
DocumentationFormat="$(Pickles_DocumentationFormat)"
Language="$(Pickles_Language)"
IncludeExperimentalFeatures="$(Pickles_IncludeExperimentalFeatures)"/>
IncludeExperimentalFeatures="$(Pickles_IncludeExperimentalFeatures)"
EnableComments="$(Pickles_EnableComments)" />
</Target>
</Project>
6 changes: 6 additions & 0 deletions src/Pickles/Pickles.ObjectModel/IConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,11 @@ public interface IConfiguration
void EnableExperimentalFeatures();

void DisableExperimentalFeatures();

bool ShouldEnableComments { get; }

void EnableComments();

void DisableComments();
}
}
18 changes: 18 additions & 0 deletions src/Pickles/Pickles.PowerShell/Pickle_Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class Pickle_Features : PSCmdlet
[Parameter(HelpMessage = CommandLineArgumentParser.HelpIncludeExperimentalFeatures, Mandatory = false)]
public SwitchParameter IncludeExperimentalFeatures { get; set; }

[Parameter(HelpMessage = CommandLineArgumentParser.HelpEnableComments, Mandatory = false)]
public string EnableComments { get; set; }

protected override void ProcessRecord()
{
var builder = new ContainerBuilder();
Expand Down Expand Up @@ -111,6 +114,21 @@ private void ParseParameters(IConfiguration configuration, IFileSystem fileSyste
{
configuration.EnableExperimentalFeatures();
}

if (this.IncludeExperimentalFeatures.IsPresent)
{
configuration.EnableExperimentalFeatures();
}

bool shouldEnableComments;

if (bool.TryParse(this.EnableComments, out shouldEnableComments))
{
if (!shouldEnableComments)
{
configuration.DisableComments();
}
}
}

private DirectoryInfoBase DetermineFeatureFolder(IFileSystem fileSystem, PathInfo currentFileSystemLocation, string directory)
Expand Down
6 changes: 6 additions & 0 deletions src/Pickles/Pickles.Test/ObjectModel/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ internal Mapper CreateMapper(string defaultLanguage = "en")
return mapper;
}

internal Mapper CreateMapper(IConfiguration configuration, string defaultLanguage = "en")
{
var mapper = new Mapper(configuration, defaultLanguage);
return mapper;
}

internal G.TableCell CreateGherkinTableCell(string cellValue)
{
return new G.TableCell(AnyLocation, cellValue);
Expand Down
44 changes: 44 additions & 0 deletions src/Pickles/Pickles.Test/ObjectModel/MapperTestsForFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,49 @@ public void MapToFeature_FeatureWithComments_ReturnsFeatureWithComments()
Check.That(scenario.Steps[3].Comments[0].Text).IsEqualTo("# line comment before the last step");
Check.That(scenario.Steps[3].Comments[1].Text).IsEqualTo("# line comment after the last step");
}

[Test]
public void MapToFeature_FeatureWithComments_ReturnsFeatureWithoutComments_WhenConfigurationSpecifies()
{
var gherkinDocument = this.factory.CreateGherkinDocument(
"My Feature",
string.Empty,
location: new G.Location(2, 0),
comments: new G.Comment[]
{
this.factory.CreateComment("# single line comment before the given step", 4, 4),
this.factory.CreateComment("# multiline comment before the then step - line 1", 6, 4),
this.factory.CreateComment("# multiline comment before the then step - line 2", 7, 4),
this.factory.CreateComment("# line comment before the last step", 10, 4),
this.factory.CreateComment("# line comment after the last step", 12, 4),
},
scenarioDefinitions: new G.ScenarioDefinition[]
{
this.factory.CreateScenario(
new string[0], "My scenario", string.Empty,
new G.Step[]
{
this.factory.CreateStep("Given", "I am on the first step", 5, 4),
this.factory.CreateStep("When", "I am on the second step", 8, 4),
this.factory.CreateStep("When", "there is a third step without comment", 9, 4),
this.factory.CreateStep("Then", "I am on the last step", 11, 4)
},
location: new G.Location(3, 0)
)
});

IConfiguration configuration = new Configuration();
configuration.DisableComments();

var mapper = this.factory.CreateMapper(configuration);

var result = mapper.MapToFeature(gherkinDocument);
var scenario = result.FeatureElements[0];

Check.That(scenario.Steps[0].Comments.Count).IsEqualTo(0);
Check.That(scenario.Steps[1].Comments.Count).IsEqualTo(0);
Check.That(scenario.Steps[2].Comments.Count).IsEqualTo(0);
Check.That(scenario.Steps[3].Comments.Count).IsEqualTo(0);
}
}
}
9 changes: 5 additions & 4 deletions src/Pickles/Pickles.UserInterface/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -109,10 +110,10 @@
<ComboBox ItemsSource="{Binding LanguageValues}" Grid.Column="1" SelectedItem="{Binding SelectedLanguage}" Grid.Row="9" Grid.ColumnSpan="2" DisplayMemberPath="NativeName" VerticalAlignment="Top"/>
<CheckBox Template="{StaticResource ResourceKey=myCheckBox}" Grid.Column="3" Grid.Row="9" IsChecked="{Binding Path=IsLanguageValid}" IsEnabled="False" VerticalAlignment="Top"/>

<mahapps:ToggleSwitch Header="Include Experimental Features" Grid.Row="10" Grid.Column="1" Grid.ColumnSpan="2" IsChecked="{Binding Path=IncludeExperimentalFeatures, Mode=TwoWay}" Margin="0,0,0,5" />

<mahapps:ToggleSwitch Header="Enable Comments" Grid.Row="10" Grid.Column="1" Grid.ColumnSpan="2" IsChecked="{Binding Path=EnableComments, Mode=TwoWay}" Margin="0,0,0,5" />
<mahapps:ToggleSwitch Header="Include Experimental Features" Grid.Row="11" Grid.Column="1" Grid.ColumnSpan="2" IsChecked="{Binding Path=IncludeExperimentalFeatures, Mode=TwoWay}" Margin="0,0,0,5" />

<Button Command="{Binding GeneratePickles}" Content="Generate" Grid.Row="11" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="24" Padding="15" Grid.ColumnSpan="2" Margin="0,20" />
<nlogViewer:NlogViewer x:Name="logCtrl" Grid.Column="0" Grid.ColumnSpan="5" Grid.Row="12" LevelWidth="auto" ExceptionWidth="auto" MessageWidth="auto" />
<Button Command="{Binding GeneratePickles}" Content="Generate" Grid.Row="12" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="24" Padding="15" Grid.ColumnSpan="2" Margin="0,20" />
<nlogViewer:NlogViewer x:Name="logCtrl" Grid.Column="0" Grid.ColumnSpan="5" Grid.Row="13" LevelWidth="auto" ExceptionWidth="auto" MessageWidth="auto" />
</Grid>
</mahapps:MetroWindow>
3 changes: 3 additions & 0 deletions src/Pickles/Pickles.UserInterface/Settings/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ public class MainModel

[DataMember(Name = "includeExperimentalFeatures", IsRequired = false)]
public bool IncludeExperimentalFeatures { get; set; }

[DataMember(Name = "enableComments", IsRequired = false)]
public bool EnableComments { get; set; }
}
}
21 changes: 20 additions & 1 deletion src/Pickles/Pickles.UserInterface/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public class MainViewModel : ViewModelBase

private bool includeExperimentalFeatures;

private bool enableComments = true;

public MainViewModel(IMainModelSerializer mainModelSerializer, IFileSystem fileSystem)
{
this.documentationFormats =
Expand Down Expand Up @@ -299,6 +301,12 @@ public bool IncludeExperimentalFeatures
set { this.Set(nameof(this.IncludeExperimentalFeatures), ref this.includeExperimentalFeatures, value); }
}

public bool EnableComments
{
get { return this.enableComments; }
set { this.Set(nameof(this.enableComments), ref this.enableComments, value); }
}

public void SaveToSettings()
{
MainModel mainModel = new MainModel
Expand All @@ -314,7 +322,8 @@ public void SaveToSettings()
DocumentationFormats =
this.documentationFormats.Where(item => item.IsSelected).Select(item => item.Item).ToArray(),
CreateDirectoryForEachOutputFormat = this.createDirectoryForEachOutputFormat,
IncludeExperimentalFeatures = this.includeExperimentalFeatures
IncludeExperimentalFeatures = this.includeExperimentalFeatures,
EnableComments = this.enableComments
};

this.mainModelSerializer.Write(mainModel);
Expand Down Expand Up @@ -349,6 +358,7 @@ public void LoadFromSettings()

this.CreateDirectoryForEachOutputFormat = mainModel.CreateDirectoryForEachOutputFormat;
this.IncludeExperimentalFeatures = mainModel.IncludeExperimentalFeatures;
this.EnableComments = mainModel.EnableComments;
}

private void DocumentationFormatsOnCollectionChanged(object sender, EventArgs notifyCollectionChangedEventArgs)
Expand Down Expand Up @@ -515,6 +525,15 @@ private void DoWork()
configuration.DisableExperimentalFeatures();
}

if (this.enableComments)
{
configuration.EnableComments();
}
else
{
configuration.DisableComments();
}

var runner = container.Resolve<Runner>();
runner.Run(container);
}
Expand Down
11 changes: 10 additions & 1 deletion src/Pickles/Pickles/CommandLineArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class CommandLineArgumentParser
public const string HelpDocumentationFormat = "the format of the output documentation";
public const string HelpTestResultsFormat = "the format of the linked test results (nunit|nunit3|xunit|xunit2|mstest |cucumberjson|specrun|vstest)";
public const string HelpIncludeExperimentalFeatures = "whether to include experimental features";
public const string HelpEnableComments = "whether to enable comments in the output";

public const string HelpTestResultsFile =
"the path to the linked test results file (can be a semicolon-separated list of files)";
Expand All @@ -56,6 +57,7 @@ public class CommandLineArgumentParser
private string testResultsFormat;
private bool versionRequested;
private bool includeExperimentalFeatures;
private string enableCommentsValue;

public CommandLineArgumentParser(IFileSystem fileSystem)
{
Expand All @@ -72,7 +74,8 @@ public CommandLineArgumentParser(IFileSystem fileSystem)
{ "df|documentation-format=", HelpDocumentationFormat, v => this.documentationFormat = v },
{ "v|version", v => this.versionRequested = v != null },
{ "h|?|help", v => this.helpRequested = v != null },
{ "exp|include-experimental-features", HelpIncludeExperimentalFeatures, v => includeExperimentalFeatures = v != null }
{ "exp|include-experimental-features", HelpIncludeExperimentalFeatures, v => this.includeExperimentalFeatures = v != null },
{ "cmt|enableComments=", HelpEnableComments, v => this.enableCommentsValue = v }
};
}

Expand Down Expand Up @@ -145,6 +148,12 @@ public bool Parse(string[] args, IConfiguration configuration, TextWriter stdout
configuration.EnableExperimentalFeatures();
}

bool enableComments;

if (bool.TryParse(this.enableCommentsValue, out enableComments) && enableComments == false)
{
configuration.DisableComments();
}

return true;
}
Expand Down
13 changes: 12 additions & 1 deletion src/Pickles/Pickles/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO.Abstractions;
using System.Reflection;
Expand Down Expand Up @@ -81,6 +80,18 @@ public void DisableExperimentalFeatures()
Features.Are.AlwaysDisabled();
}

public bool ShouldEnableComments { get; private set; } = true;

public void EnableComments()
{
this.ShouldEnableComments = true;
}

public void DisableComments()
{
this.ShouldEnableComments = false;
}

public bool ShouldIncludeExperimentalFeatures { get; private set; }

public void AddTestResultFile(FileInfoBase fileInfoBase)
Expand Down
2 changes: 1 addition & 1 deletion src/Pickles/Pickles/FeatureParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Feature Parse(TextReader featureFileReader)
new Gherkin.TokenScanner(featureFileReader),
new Gherkin.TokenMatcher(language));

Feature result = new Mapper(gherkinDocument.Feature.Language).MapToFeature(gherkinDocument);
Feature result = new Mapper(this.configuration, gherkinDocument.Feature.Language).MapToFeature(gherkinDocument);

return result;
}
Expand Down
18 changes: 14 additions & 4 deletions src/Pickles/Pickles/ObjectModel/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ namespace PicklesDoc.Pickles.ObjectModel
{
public class Mapper
{
private readonly IConfiguration configuration;

private readonly LanguageServices languageServices;

public Mapper(string featureLanguage = LanguageServices.DefaultLanguage)
: this(new Configuration(), featureLanguage)
{ }

public Mapper(IConfiguration configuration, string featureLanguage = LanguageServices.DefaultLanguage)
{
this.configuration = configuration;
this.languageServices = new LanguageServices(featureLanguage);
}
}

public string MapToString(G.TableCell cell)
{
Expand Down Expand Up @@ -234,7 +241,10 @@ public Feature MapToFeature(G.GherkinDocument gherkinDocument)
feature.AddBackground(this.MapToScenario(background));
}

feature.Comments.AddRange((gherkinDocument.Comments ?? new G.Comment[0]).Select(this.MapToComment));
if (this.configuration.ShouldEnableComments)
{
feature.Comments.AddRange((gherkinDocument.Comments ?? new G.Comment[0]).Select(this.MapToComment));
}

feature.Description = gherkinDocument.Feature.Description ?? string.Empty;

Expand All @@ -256,14 +266,14 @@ public Feature MapToFeature(G.GherkinDocument gherkinDocument)
var relatedFeatureElement = feature.FeatureElements.LastOrDefault(x => x.Location.Line < comment.Location.Line);
// Find the step to which the comment is related to
if (relatedFeatureElement != null)
{
{
var stepAfterComment = relatedFeatureElement.Steps.FirstOrDefault(x => x.Location.Line > comment.Location.Line);
if (stepAfterComment != null)
{
// Comment is before a step
comment.Type = CommentType.StepComment;
stepAfterComment.Comments.Add(comment);
}
}
else
{
// Comment is located after the last step
Expand Down
Loading

0 comments on commit 4d2ff43

Please sign in to comment.