Skip to content

Commit

Permalink
Added new tool (console app) for building snippet listing table
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Feb 27, 2014
1 parent 31db085 commit bd0ab72
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ListingBuilder/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
58 changes: 58 additions & 0 deletions ListingBuilder/ListingBuilder.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C5E392D6-D12C-4361-9E5C-5358DCCCB1C9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ListingBuilder</RootNamespace>
<AssemblyName>ListingBuilder</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
48 changes: 48 additions & 0 deletions ListingBuilder/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace ListingBuilder
{
class Program
{
static void Main(string[] args)
{
string readPath = @"C:\Projects\Visual-Studio-jQuery-Code-Snippets\jQueryCodeSnippets";
string listingFilePath = @"C:\Projects\Visual-Studio-jQuery-Code-Snippets\SnippetListing.html";
StringBuilder tableSb = new StringBuilder();

tableSb.AppendLine("<table>");
tableSb.AppendLine("<thead>");
tableSb.AppendLine("<tr><th>Type</th><th>Shortcut</th><th>Description</th></tr>");
tableSb.AppendLine("</thead>");
tableSb.AppendLine("<tbody>");

foreach (var snippetFile in Directory.EnumerateFiles(readPath, "*.snippet", SearchOption.AllDirectories).OrderBy(i => i))
{
var snippetDoc = new XmlDocument();
snippetDoc.Load(snippetFile);

var shortcutNode = snippetDoc.GetElementsByTagName("Shortcut");
var shortcut = shortcutNode[0].InnerText;

var descriptionNode = snippetDoc.GetElementsByTagName("Description");
var description = descriptionNode[0].InnerText;

tableSb.AppendLine(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", snippetFile.Contains("\\HTML") ? "HTML" : "JavaScript", shortcut, description));
}

tableSb.AppendLine("</tbody>");
tableSb.AppendLine("</table>");

using (StreamWriter writer = new StreamWriter(listingFilePath, false))
{
writer.WriteLine(tableSb.ToString());
}
}
}
}
36 changes: 36 additions & 0 deletions ListingBuilder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ListingBuilder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ListingBuilder")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e0a22101-6ff3-40a2-a3fa-05f268addfac")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit bd0ab72

Please sign in to comment.