Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions MarkdownDocNet.sln → VSDocumentGeneratorSolution.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDocNet", "MarkdownDocNet\MarkdownDocNet.csproj", "{177B50B5-4561-443B-BAFD-A3AB19519324}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDocNet", "src\MarkdownDocNet\MarkdownDocNet.csproj", "{177B50B5-4561-443B-BAFD-A3AB19519324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualStudio.DocumentGenerator.Vsix", "src\VisualStudio.DocumentGenerator.Vsix\VisualStudio.DocumentGenerator.Vsix.csproj", "{3CF8B458-7D40-4207-9F76-3AAADCEA8344}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,8 +17,15 @@ Global
{177B50B5-4561-443B-BAFD-A3AB19519324}.Debug|Any CPU.Build.0 = Debug|Any CPU
{177B50B5-4561-443B-BAFD-A3AB19519324}.Release|Any CPU.ActiveCfg = Release|Any CPU
{177B50B5-4561-443B-BAFD-A3AB19519324}.Release|Any CPU.Build.0 = Release|Any CPU
{3CF8B458-7D40-4207-9F76-3AAADCEA8344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CF8B458-7D40-4207-9F76-3AAADCEA8344}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CF8B458-7D40-4207-9F76-3AAADCEA8344}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CF8B458-7D40-4207-9F76-3AAADCEA8344}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C8DE249-EF2B-4C6E-A329-6794BB52C856}
EndGlobalSection
EndGlobal
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{177B50B5-4561-443B-BAFD-A3AB19519324}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MarkdownDocNet</RootNamespace>
<AssemblyName>MarkdownDocNet</AssemblyName>
Expand Down Expand Up @@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
56 changes: 56 additions & 0 deletions src/VisualStudio.DocumentGenerator.Vsix/ActiveDocumentRestorer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using EnvDTE;
using System;

namespace MarkdownVsix
{
/// <summary>
/// A class that handles tracking a document and switching back to it, typically in a using
/// statement context.
/// </summary>
internal class ActiveDocumentRestorer : IDisposable
{
#region Constructors

/// <summary>Initializes a new instance of the <see cref="ActiveDocumentRestorer"/> class.</summary>
/// <param name="package">The hosting package.</param>
internal ActiveDocumentRestorer(GenerateMarkdownPackage package)
{
Package = package;

StartTracking();
}

#endregion Constructors

/// <summary>Gets or sets the hosting package.</summary>
private GenerateMarkdownPackage Package { get; set; }

/// <summary>Gets or sets the active document.</summary>
private Document TrackedDocument { get; set; }

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting
/// unmanaged resources.
/// </summary>
public void Dispose()
{
RestoreTrackedDocument();
}

/// <summary>Restores the tracked document if not already active.</summary>
internal void RestoreTrackedDocument()
{
if (TrackedDocument != null && Package.ActiveDocument != TrackedDocument)
{
TrackedDocument.Activate();
}
}

/// <summary>Starts tracking the active document.</summary>
internal void StartTracking()
{
// Cache the active document.
TrackedDocument = Package.ActiveDocument;
}
}
}
59 changes: 59 additions & 0 deletions src/VisualStudio.DocumentGenerator.Vsix/Commands/BaseCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.VisualStudio.Shell;
using System;
using System.ComponentModel.Design;

namespace MarkdownVsix
{
/// <summary>The base implementation of a command.</summary>
internal abstract class BaseCommand : OleMenuCommand
{
/// <summary>Gets the hosting package.</summary>
protected GenerateMarkdownPackage Package { get; private set; }

/// <summary>Initializes a new instance of the <see cref="BaseCommand"/> class.</summary>
/// <param name="package">The hosting package.</param>
/// <param name="id"> The id for the command.</param>
protected BaseCommand(GenerateMarkdownPackage package, CommandID id)
: base(BaseCommand_Execute, id)
{
Package = package;

BeforeQueryStatus += BaseCommand_BeforeQueryStatus;
}

/// <summary>Called to update the current status of the command.</summary>
protected virtual void OnBeforeQueryStatus()
{
// By default, commands are always enabled.
Enabled = true;
}

/// <summary>Called to execute the command.</summary>
protected virtual void OnExecute()
{
//OutputWindowHelper.DiagnosticWriteLine($"{GetType().Name}.OnExecute invoked");
}

/// <summary>Handles the BeforeQueryStatus event of the BaseCommand control.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">
/// The <see cref="System.EventArgs"/> instance containing the event data.
/// </param>
private static void BaseCommand_BeforeQueryStatus(object sender, EventArgs e)
{
BaseCommand command = sender as BaseCommand;
command?.OnBeforeQueryStatus();
}

/// <summary>Handles the Execute event of the BaseCommand control.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">
/// The <see cref="System.EventArgs"/> instance containing the event data.
/// </param>
private static void BaseCommand_Execute(object sender, EventArgs e)
{
BaseCommand command = sender as BaseCommand;
command?.OnExecute();
}
}
}
30 changes: 30 additions & 0 deletions src/VisualStudio.DocumentGenerator.Vsix/Commands/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

namespace MarkdownVsix
{
public class Constants
{
public const string DocExtension = ".xml";

/// <summary>Caminho do diretório dos arquivos</summary>
public const string ProjectDocPath = "AutoDocs";

public static class PackageGuids
{
public const string PackageGuidString = ("d69f1580-274f-4d12-b13a-c365c759de66");

public readonly static Guid SymbolGenDocProjectNodeGroup = new Guid("1ebc1a20-d2e7-4875-a7ff-2a3219b14686");

public readonly static Guid SymbolGenDocSolutionFolderGroup = new Guid("1ebc1a20-d2e7-4875-a7ff-2a3219b14685");
public readonly static Guid SymbolGenDocSolutionNodeGroup = new Guid("1ebc1a20-d2e7-4875-a7ff-2a3219b14683");
}

/// <summary>Helper class that exposes all GUIDs used across VS Package.</summary>
public sealed partial class PackageIds
{
public const int CmdIDSymbolGenDocProjectNodeGroup = 0x1052;
public const int CmdIDSymbolGenDocSolutionFolderGroup = 0x1051;
public const int CmdIDSymbolGenDocSolutionNodeGroup = 0x1050;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using EnvDTE;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.IO;
using System.Linq;
using VisualStudio.DocumentGenerate.Vsix.Format.Markdown;

namespace MarkdownVsix
{
/// <summary>A command that provides for cleaning up code in the selected documents.</summary>
internal class CreateMarkdownProjectCommand : BaseCommand
{
/// <summary>Gets the list of selected project items.</summary>
private IEnumerable<ProjectItem> SelectedProjectItems
{
get
{
return SolutionHelper.GetSelectedProjectItemsRecursively(Package);
}
}

/// <summary>
/// Initializes a new instance of the <see cref="CreateMarkdownProjectCommand"/> class.
/// </summary>
/// <param name="package">The hosting package.</param>
internal CreateMarkdownProjectCommand(GenerateMarkdownPackage package)
: this(package, new CommandID(Constants.PackageGuids.SymbolGenDocProjectNodeGroup, Constants.PackageIds.CmdIDSymbolGenDocProjectNodeGroup))
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CreateMarkdownProjectCommand"/> class.
/// </summary>
/// <param name="package">The hosting package.</param>
internal CreateMarkdownProjectCommand(GenerateMarkdownPackage package, CommandID command)
: base(package, command)
{
}

/// <summary>Called to update the current status of the command.</summary>
protected override void OnBeforeQueryStatus()
{
Enabled = Package.IDE.Solution.IsOpen;
}

/// <summary>Called to execute the command.</summary>
protected override void OnExecute()
{
base.OnExecute();
Package.IDE.Solution.SolutionBuild.Clean(true);
// Package.IDE.Solution.SolutionBuild.Build(true);

Console.WriteLine("Iniciando a geração de documentos");

if (SelectedProjectItems?.Any() == false)
{
Console.WriteLine("Não foi encontrado nenhum projeto selecionado");
return;
}

using (var document = new ActiveDocumentRestorer(Package))
{
//const string documentationFile = "DocumentationFile";
const string projectFullName = "Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject";


//&& (a.ContainingProject.Properties?.Item(documentationFile) != null)
var projects = SelectedProjectItems
.Where(a => a.ContainingProject != null &&
a.ContainingProject.GetType().FullName == projectFullName)
.Select(a => new ProjectFile(a.ContainingProject))
.Where(a => !string.IsNullOrWhiteSpace(a.DocFile) && !a.InvalidProject)
.Distinct()
.ToArray();

Console.WriteLine("Foram encontrados {0}/{1} arquivos xml", projects.Length, SelectedProjectItems.Count());

var solutionDirectory = Path.GetDirectoryName(Package.IDE.Solution.FullName);
solutionDirectory = Path.Combine(solutionDirectory, Constants.ProjectDocPath);

foreach (var project in projects)
{
Debug.WriteLine($"Executando {project.DocName}");
Package.IDE.StatusBar.Text = $"Executando {project.DocName}";

var parser = new MarkdownParse(project.DocFile, project.AssemblyFile, solutionDirectory);
Package.IDE.Solution.SolutionBuild.BuildProject("Debug", project.UniqueName, true);
parser.ParseXml();
parser.GenerateDoc();
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.ComponentModel.Design;

namespace MarkdownVsix
{
internal class CreateMarkdownSolutionCommand : CreateMarkdownProjectCommand
{
internal CreateMarkdownSolutionCommand(GenerateMarkdownPackage package)
: base(package, new CommandID(Constants.PackageGuids.SymbolGenDocSolutionNodeGroup, Constants.PackageIds.CmdIDSymbolGenDocSolutionNodeGroup))
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.ComponentModel.Design;

namespace MarkdownVsix
{
internal class CreateMarkdownSolutionFolderCommand : CreateMarkdownProjectCommand
{
internal CreateMarkdownSolutionFolderCommand(GenerateMarkdownPackage package)
: base(package, new CommandID(Constants.PackageGuids.SymbolGenDocSolutionFolderGroup, Constants.PackageIds.CmdIDSymbolGenDocSolutionFolderGroup))
{
}
}
}
45 changes: 45 additions & 0 deletions src/VisualStudio.DocumentGenerator.Vsix/Format/DocFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Reflection;
using System.Text;

namespace VSDocument.Format.Markdown
{
public abstract class DocFormat
{
protected virtual void WriteInfo(MethodInfo[] methods, StringBuilder output)
{
}

protected virtual void WriteInfo(PropertyInfo[] properties, StringBuilder output)
{
}

protected virtual void WriteInfo(FieldInfo[] fields, StringBuilder output)
{
}

protected virtual void WriteInfo(EventInfo[] events, StringBuilder output)
{
}

protected virtual void WriteInfo(ConstructorInfo[] events, StringBuilder output)
{
}

protected virtual void WriteInfo(Type type, StringBuilder output)
{
}

protected virtual void WriteStatic(FieldInfo[] staticFields, StringBuilder output)
{
}

protected virtual void WriteStatic(MethodInfo[] staticMethods, StringBuilder output)
{
}

protected virtual void WriteStatic(PropertyInfo[] staticProperties, StringBuilder output)
{
}
}
}
Loading