Primera version

This commit is contained in:
Miguel 2025-03-26 09:32:23 +01:00
commit 3f46f8aa48
24 changed files with 2036 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored Normal file
View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

9
App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="NetDocsForLLM.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:NetDocsForLLM"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

45
App.xaml.cs Normal file
View File

@ -0,0 +1,45 @@
using Microsoft.Extensions.DependencyInjection;
using NetDocsForLLM.Services;
using NetDocsForLLM.ViewModels;
using System;
using System.Windows;
namespace NetDocsForLLM
{
public partial class App : Application
{
private readonly ServiceProvider _serviceProvider;
public App()
{
ServiceCollection services = new();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
}
private void ConfigureServices(ServiceCollection services)
{
// Register services
services.AddSingleton<IDocFxService, DocFxService>();
services.AddSingleton<IDocumentationGenerator, DocumentationGenerator>();
services.AddSingleton<IAssemblyAnalyzer, AssemblyAnalyzer>();
// Register ViewModels
services.AddSingleton<MainViewModel>();
services.AddTransient<DocumentationViewModel>();
services.AddTransient<ExportViewModel>();
// Register Views
services.AddSingleton<MainWindow>();
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
mainWindow.DataContext = _serviceProvider.GetRequiredService<MainViewModel>();
mainWindow.Show();
}
}
}

10
AssemblyInfo.cs Normal file
View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly:ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

99
Helpers/DocFxHelper.cs Normal file
View File

@ -0,0 +1,99 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace NetDocsForLLM.Helpers
{
public static class DocFxHelper
{
public static async Task<string> CreateDocFxConfigAsync(string outputPath, params string[] assemblyPaths)
{
if (string.IsNullOrEmpty(outputPath))
throw new ArgumentException("Ruta de salida no válida", nameof(outputPath));
if (assemblyPaths == null || assemblyPaths.Length == 0)
throw new ArgumentException("Debe proporcionar al menos una ruta de ensamblado", nameof(assemblyPaths));
var configPath = Path.Combine(outputPath, "docfx.json");
var config = GenerateDocFxConfigContent(assemblyPaths);
try
{
await File.WriteAllTextAsync(configPath, config);
return configPath;
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al crear configuración de DocFX: {ex.Message}", ex);
}
}
private static string GenerateDocFxConfigContent(string[] assemblyPaths)
{
var files = string.Join("\",\n \"", assemblyPaths.Select(p => p.Replace("\\", "\\\\")));
return $@"
{{
""metadata"": [
{{
""src"": [
{{
""files"": [
""{files}""
],
""src"": "".""
}}
],
""dest"": ""obj/api"",
""properties"": {{
""TargetFramework"": ""net6.0""
}},
""disableGitFeatures"": true,
""disableDefaultFilter"": false
}}
],
""build"": {{
""content"": [
{{
""files"": [""*.yml""],
""src"": ""obj/api"",
""dest"": ""api""
}}
],
""resource"": [
{{
""files"": [""images/**""],
""exclude"": [""obj/**"", ""_site/**""]
}}
],
""dest"": ""_site"",
""globalMetadataFiles"": [],
""fileMetadataFiles"": [],
""template"": [""default""],
""postProcessors"": [],
""markdownEngineName"": ""markdig"",
""noLangKeyword"": false,
""keepFileLink"": false,
""cleanupCacheHistory"": false,
""disableGitFeatures"": false
}}
}}";
}
public static XDocument ParseXmlComments(string xmlPath)
{
if (string.IsNullOrEmpty(xmlPath) || !File.Exists(xmlPath))
return null;
try
{
return XDocument.Load(xmlPath);
}
catch (Exception)
{
return null;
}
}
}
}

59
Helpers/JsonHelper.cs Normal file
View File

@ -0,0 +1,59 @@
using NetDocsForLLM.Models;
using Newtonsoft.Json;
using System;
using System.IO;
namespace NetDocsForLLM.Helpers
{
public static class JsonHelper
{
public static string SerializeToJson(DocumentationModel documentation, bool indented = true)
{
try
{
var settings = new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
NullValueHandling = NullValueHandling.Ignore
};
return JsonConvert.SerializeObject(documentation,
indented ? Formatting.Indented : Formatting.None,
settings);
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al serializar a JSON: {ex.Message}", ex);
}
}
public static void SaveToJsonFile(DocumentationModel documentation, string filePath)
{
try
{
var json = SerializeToJson(documentation);
File.WriteAllText(filePath, json);
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al guardar archivo JSON: {ex.Message}", ex);
}
}
public static DocumentationModel DeserializeFromJson(string json)
{
try
{
return JsonConvert.DeserializeObject<DocumentationModel>(json,
new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al deserializar desde JSON: {ex.Message}", ex);
}
}
}
}

202
MainWindow.xaml Normal file
View File

@ -0,0 +1,202 @@
<Window x:Class="NetDocsForLLM.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NetDocsForLLM"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="NetDocs para LLMs" Height="650" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Encabezado -->
<Border Background="#2c3e50" Padding="15">
<StackPanel>
<TextBlock Text="Generador de Documentación .NET para LLMs"
Foreground="White"
FontSize="22"
HorizontalAlignment="Center"/>
<TextBlock Text="Extraiga y estructure documentación de librerías .NET para uso con modelos de lenguaje"
Foreground="#ecf0f1"
FontSize="12"
HorizontalAlignment="Center"
Margin="0,5,0,0"/>
</StackPanel>
</Border>
<!-- Contenido principal -->
<TabControl Grid.Row="1" Margin="10">
<TabItem Header="Selección de Librería">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Content="Seleccionar Archivos DLL..."
Command="{Binding SelectAssembliesCommand}"
Padding="10,5"
Margin="0,0,0,10"/>
<TextBlock Grid.Row="1"
Text="Librerías seleccionadas:"
FontWeight="Bold"
Margin="0,10,0,5"/>
<ListView Grid.Row="2"
ItemsSource="{Binding SelectedAssemblies}"
Margin="0,5">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
<TextBlock Text="{Binding FilePath}" FontSize="11" TextWrapping="Wrap"/>
</StackPanel>
<Button Grid.Column="1"
Content="X"
Command="{Binding DataContext.RemoveAssemblyCommand, RelativeSource={RelativeSource AncestorType=ListView}}"
CommandParameter="{Binding}"
Margin="5,0,0,0"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Grid.Row="3"
Content="Analizar y Generar Documentación"
Command="{Binding GenerateDocumentationCommand}"
IsEnabled="{Binding HasSelectedAssemblies}"
Padding="10,5"
Margin="0,10,0,0"
Background="#2980b9"
Foreground="White"/>
</Grid>
</TabItem>
<TabItem Header="Configuración" IsEnabled="{Binding HasSelectedAssemblies}">
<ScrollViewer>
<StackPanel Margin="10">
<GroupBox Header="Opciones de documentación">
<StackPanel Margin="5">
<CheckBox Content="Incluir métodos privados"
IsChecked="{Binding Settings.IncludePrivateMembers}"
Margin="0,5"/>
<CheckBox Content="Incluir miembros heredados"
IsChecked="{Binding Settings.IncludeInheritedMembers}"
Margin="0,5"/>
<CheckBox Content="Incluir ejemplos de código"
IsChecked="{Binding Settings.IncludeExamples}"
Margin="0,5"/>
<CheckBox Content="Procesamiento detallado de comentarios XML"
IsChecked="{Binding Settings.DetailedXmlComments}"
Margin="0,5"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Nivel de detalle" Margin="0,10,0,0">
<StackPanel Margin="5">
<RadioButton Content="Básico - Solo información esencial"
IsChecked="{Binding Settings.DetailLevel, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Basic}"
GroupName="DetailLevel"
Margin="0,5"/>
<RadioButton Content="Estándar - Equilibrio entre detalle y tamaño"
IsChecked="{Binding Settings.DetailLevel, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Standard}"
GroupName="DetailLevel"
Margin="0,5"/>
<RadioButton Content="Completo - Toda la información disponible"
IsChecked="{Binding Settings.DetailLevel, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Full}"
GroupName="DetailLevel"
Margin="0,5"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Formato de salida" Margin="0,10,0,0">
<StackPanel Margin="5">
<RadioButton Content="JSON"
IsChecked="{Binding Settings.OutputFormat, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Json}"
GroupName="OutputFormat"
Margin="0,5"/>
<RadioButton Content="YAML"
IsChecked="{Binding Settings.OutputFormat, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Yaml}"
GroupName="OutputFormat"
Margin="0,5"/>
</StackPanel>
</GroupBox>
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Previsualización" IsEnabled="{Binding HasGeneratedDocumentation}">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<Button Content="Copiar al portapapeles"
Command="{Binding CopyToClipboardCommand}"
Padding="10,5"
Margin="0,0,10,0"/>
<Button Content="Exportar..."
Command="{Binding ExportDocumentationCommand}"
Padding="10,5"/>
</StackPanel>
<xctk:PropertyGrid Grid.Row="1"
SelectedObject="{Binding DocumentationModel}"
AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition Name="Namespaces" DisplayName="Espacios de nombres"/>
<!-- Más definiciones según la estructura del modelo -->
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
<Border Grid.Row="1" Background="#f5f5f5" BorderBrush="#ddd" BorderThickness="1">
<TextBox Text="{Binding DocumentationPreview, Mode=OneWay}"
IsReadOnly="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
FontFamily="Consolas"
AcceptsReturn="True"
Padding="10"/>
</Border>
<TextBlock Grid.Row="2"
Text="{Binding DocumentationStats}"
Margin="0,10,0,0"/>
</Grid>
</TabItem>
</TabControl>
<!-- Pie de página -->
<StatusBar Grid.Row="2">
<StatusBarItem>
<TextBlock Text="{Binding StatusMessage}"/>
</StatusBarItem>
<StatusBarItem HorizontalAlignment="Right">
<ProgressBar Width="100" Height="15" IsIndeterminate="{Binding IsProcessing}"/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>

12
MainWindow.xaml.cs Normal file
View File

@ -0,0 +1,12 @@
using System.Windows;
namespace NetDocsForLLM
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

51
Models/AssemblyModel.cs Normal file
View File

@ -0,0 +1,51 @@
using System;
using System.Reflection;
using CommunityToolkit.Mvvm.ComponentModel;
namespace NetDocsForLLM.Models
{
public class AssemblyModel : ObservableObject
{
private string _filePath;
private string _name;
private Version _version;
private bool _hasXmlDocumentation;
public string FilePath
{
get => _filePath;
set => SetProperty(ref _filePath, value);
}
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public Version Version
{
get => _version;
set => SetProperty(ref _version, value);
}
public bool HasXmlDocumentation
{
get => _hasXmlDocumentation;
set => SetProperty(ref _hasXmlDocumentation, value);
}
public Assembly? LoadedAssembly { get; set; }
public string XmlDocPath { get; set; }
public AssemblyModel(string filePath)
{
_filePath = filePath;
_name = System.IO.Path.GetFileName(filePath);
_version = new Version(1, 0);
_hasXmlDocumentation = false;
XmlDocPath = string.Empty;
}
}
}

View File

@ -0,0 +1,237 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
namespace NetDocsForLLM.Models
{
public class DocumentationModel : ObservableObject
{
private ObservableCollection<NamespaceDocumentation> _namespaces;
public ObservableCollection<NamespaceDocumentation> Namespaces
{
get => _namespaces;
set => SetProperty(ref _namespaces, value);
}
public DocumentationModel()
{
_namespaces = new ObservableCollection<NamespaceDocumentation>();
}
}
public class NamespaceDocumentation : ObservableObject
{
private string _name;
private string _description;
private ObservableCollection<TypeDocumentation> _types;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public string Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public ObservableCollection<TypeDocumentation> Types
{
get => _types;
set => SetProperty(ref _types, value);
}
public NamespaceDocumentation()
{
_name = string.Empty;
_description = string.Empty;
_types = new ObservableCollection<TypeDocumentation>();
}
}
public class TypeDocumentation : ObservableObject
{
private string _name;
private string _fullName;
private string _description;
private string _typeKind; // Class, Interface, Enum, etc.
private ObservableCollection<MemberDocumentation> _members;
private ObservableCollection<string> _baseTypes;
private ObservableCollection<string> _interfaces;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public string FullName
{
get => _fullName;
set => SetProperty(ref _fullName, value);
}
public string Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public string TypeKind
{
get => _typeKind;
set => SetProperty(ref _typeKind, value);
}
public ObservableCollection<MemberDocumentation> Members
{
get => _members;
set => SetProperty(ref _members, value);
}
public ObservableCollection<string> BaseTypes
{
get => _baseTypes;
set => SetProperty(ref _baseTypes, value);
}
public ObservableCollection<string> Interfaces
{
get => _interfaces;
set => SetProperty(ref _interfaces, value);
}
public TypeDocumentation()
{
_name = string.Empty;
_fullName = string.Empty;
_description = string.Empty;
_typeKind = string.Empty;
_members = new ObservableCollection<MemberDocumentation>();
_baseTypes = new ObservableCollection<string>();
_interfaces = new ObservableCollection<string>();
}
}
public class MemberDocumentation : ObservableObject
{
private string _name;
private string _description;
private string _memberType; // Method, Property, Field, etc.
private string _signature;
private ObservableCollection<ParameterDocumentation> _parameters;
private string _returnType;
private string _returnDescription;
private ObservableCollection<string> _examples;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public string Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public string MemberType
{
get => _memberType;
set => SetProperty(ref _memberType, value);
}
public string Signature
{
get => _signature;
set => SetProperty(ref _signature, value);
}
public ObservableCollection<ParameterDocumentation> Parameters
{
get => _parameters;
set => SetProperty(ref _parameters, value);
}
public string ReturnType
{
get => _returnType;
set => SetProperty(ref _returnType, value);
}
public string ReturnDescription
{
get => _returnDescription;
set => SetProperty(ref _returnDescription, value);
}
public ObservableCollection<string> Examples
{
get => _examples;
set => SetProperty(ref _examples, value);
}
public MemberDocumentation()
{
_name = string.Empty;
_description = string.Empty;
_memberType = string.Empty;
_signature = string.Empty;
_parameters = new ObservableCollection<ParameterDocumentation>();
_returnType = string.Empty;
_returnDescription = string.Empty;
_examples = new ObservableCollection<string>();
}
}
public class ParameterDocumentation : ObservableObject
{
private string _name;
private string _type;
private string _description;
private bool _isOptional;
private string _defaultValue;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public string Type
{
get => _type;
set => SetProperty(ref _type, value);
}
public string Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public bool IsOptional
{
get => _isOptional;
set => SetProperty(ref _isOptional, value);
}
public string DefaultValue
{
get => _defaultValue;
set => SetProperty(ref _defaultValue, value);
}
public ParameterDocumentation()
{
_name = string.Empty;
_type = string.Empty;
_description = string.Empty;
_isOptional = false;
_defaultValue = string.Empty;
}
}
}

74
Models/ExportSettings.cs Normal file
View File

@ -0,0 +1,74 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace NetDocsForLLM.Models
{
public enum DetailLevel
{
Basic,
Standard,
Full
}
public enum OutputFormat
{
Json,
Yaml
}
public class ExportSettings : ObservableObject
{
private bool _includePrivateMembers;
private bool _includeInheritedMembers;
private bool _includeExamples;
private bool _detailedXmlComments;
private DetailLevel _detailLevel;
private OutputFormat _outputFormat;
public bool IncludePrivateMembers
{
get => _includePrivateMembers;
set => SetProperty(ref _includePrivateMembers, value);
}
public bool IncludeInheritedMembers
{
get => _includeInheritedMembers;
set => SetProperty(ref _includeInheritedMembers, value);
}
public bool IncludeExamples
{
get => _includeExamples;
set => SetProperty(ref _includeExamples, value);
}
public bool DetailedXmlComments
{
get => _detailedXmlComments;
set => SetProperty(ref _detailedXmlComments, value);
}
public DetailLevel DetailLevel
{
get => _detailLevel;
set => SetProperty(ref _detailLevel, value);
}
public OutputFormat OutputFormat
{
get => _outputFormat;
set => SetProperty(ref _outputFormat, value);
}
public ExportSettings()
{
// Default settings
_includePrivateMembers = false;
_includeInheritedMembers = true;
_includeExamples = true;
_detailedXmlComments = true;
_detailLevel = DetailLevel.Standard;
_outputFormat = OutputFormat.Json;
}
}
}

19
NetDocsForLLM.csproj Normal file
View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="docfx.console" Version="2.59.4" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
</ItemGroup>
</Project>

25
NetDocsForLLM.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35806.99 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDocsForLLM", "NetDocsForLLM.csproj", "{F2A6DD12-A1A1-4404-A7DD-D1FCDC96055C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F2A6DD12-A1A1-4404-A7DD-D1FCDC96055C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2A6DD12-A1A1-4404-A7DD-D1FCDC96055C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2A6DD12-A1A1-4404-A7DD-D1FCDC96055C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2A6DD12-A1A1-4404-A7DD-D1FCDC96055C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7E9896E1-8CA1-4018-980B-6320E8545174}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,49 @@
using NetDocsForLLM.Models;
using System;
using System.IO;
using System.Reflection;
namespace NetDocsForLLM.Services
{
public interface IAssemblyAnalyzer
{
AssemblyModel LoadAssembly(string filePath);
}
public class AssemblyAnalyzer : IAssemblyAnalyzer
{
public AssemblyModel LoadAssembly(string filePath)
{
if (string.IsNullOrEmpty(filePath))
throw new ArgumentException("Ruta de archivo no válida", nameof(filePath));
if (!File.Exists(filePath))
throw new FileNotFoundException($"No se encontró el archivo: {filePath}");
var assemblyModel = new AssemblyModel(filePath);
try
{
// Load assembly
var assembly = Assembly.LoadFrom(filePath);
assemblyModel.LoadedAssembly = assembly;
assemblyModel.Name = assembly.GetName().Name;
assemblyModel.Version = assembly.GetName().Version;
// Check for XML documentation
var xmlFilePath = Path.ChangeExtension(filePath, ".xml");
if (File.Exists(xmlFilePath))
{
assemblyModel.HasXmlDocumentation = true;
assemblyModel.XmlDocPath = xmlFilePath;
}
return assemblyModel;
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al cargar el ensamblado: {ex.Message}", ex);
}
}
}
}

174
Services/DocFxService.cs Normal file
View File

@ -0,0 +1,174 @@
using NetDocsForLLM.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
namespace NetDocsForLLM.Services
{
public interface IDocFxService
{
Task<string> GenerateMetadataAsync(IEnumerable<AssemblyModel> assemblies);
}
public class DocFxService : IDocFxService
{
private readonly string _workingDirectory;
private readonly string _docfxPath;
public DocFxService()
{
// Create a temporary working directory
_workingDirectory = Path.Combine(Path.GetTempPath(), "NetDocsForLLM_" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(_workingDirectory);
// Locate DocFX executable in the packages directory
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
_docfxPath = Path.Combine(baseDir, "docfx", "docfx.exe");
// If not found in the default location, try to locate it in the packages directory
if (!File.Exists(_docfxPath))
{
var packagesDir = Path.Combine(baseDir, "..", "..", "..", "packages");
var docfxPaths = Directory.GetFiles(packagesDir, "docfx.exe", SearchOption.AllDirectories);
if (docfxPaths.Length > 0)
{
_docfxPath = docfxPaths[0];
}
else
{
throw new FileNotFoundException("No se pudo encontrar docfx.exe. Asegúrese de que el paquete docfx.console esté instalado.");
}
}
}
public async Task<string> GenerateMetadataAsync(IEnumerable<AssemblyModel> assemblies)
{
try
{
// Create DocFX configuration
var configPath = Path.Combine(_workingDirectory, "docfx.json");
var config = CreateDocFxConfig(assemblies);
File.WriteAllText(configPath, config);
// Run DocFX metadata
var result = await RunDocFxMetadataAsync(configPath);
// Return path to the generated metadata
var apiPath = Path.Combine(_workingDirectory, "obj", "api");
return apiPath;
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al generar metadatos con DocFX: {ex.Message}", ex);
}
}
private string CreateDocFxConfig(IEnumerable<AssemblyModel> assemblies)
{
var assemblyPaths = new List<string>();
var xmlPaths = new List<string>();
foreach (var assembly in assemblies)
{
assemblyPaths.Add(assembly.FilePath);
if (assembly.HasXmlDocumentation)
{
xmlPaths.Add(assembly.XmlDocPath);
}
}
return $@"
{{
""metadata"": [
{{
""src"": [
{{
""files"": [
""{string.Join("\",\n \"", assemblyPaths.Select(p => p.Replace("\\", "\\\\")))}""
],
""src"": "".""
}}
],
""dest"": ""obj/api"",
""properties"": {{
""TargetFramework"": ""net6.0""
}},
""disableGitFeatures"": true,
""disableDefaultFilter"": false
}}
],
""build"": {{
""content"": [
{{
""files"": [""*.yml""],
""src"": ""obj/api"",
""dest"": ""api""
}}
],
""resource"": [
{{
""files"": [""images/**""],
""exclude"": [""obj/**"", ""_site/**""]
}}
],
""dest"": ""_site"",
""globalMetadataFiles"": [],
""fileMetadataFiles"": [],
""template"": [""default""],
""postProcessors"": [],
""markdownEngineName"": ""markdig"",
""noLangKeyword"": false,
""keepFileLink"": false,
""cleanupCacheHistory"": false,
""disableGitFeatures"": false
}}
}}";
}
private async Task<string> RunDocFxMetadataAsync(string configPath)
{
var startInfo = new ProcessStartInfo
{
FileName = _docfxPath,
Arguments = $"metadata \"{configPath}\"",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = _workingDirectory
};
using var process = new Process { StartInfo = startInfo };
var outputBuilder = new System.Text.StringBuilder();
var errorBuilder = new System.Text.StringBuilder();
process.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
outputBuilder.AppendLine(e.Data);
};
process.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
errorBuilder.AppendLine(e.Data);
};
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
await process.WaitForExitAsync();
if (process.ExitCode != 0)
{
throw new InvalidOperationException(
$"DocFX metadata falló con código de salida {process.ExitCode}. Error: {errorBuilder}");
}
return outputBuilder.ToString();
}
}
}

View File

@ -0,0 +1,198 @@
using NetDocsForLLM.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace NetDocsForLLM.Services
{
public interface IDocumentationGenerator
{
Task<DocumentationModel> GenerateDocumentation(IEnumerable<AssemblyModel> assemblies, ExportSettings settings);
string GenerateDocumentationPreview(DocumentationModel documentation, ExportSettings settings);
}
public class DocumentationGenerator : IDocumentationGenerator
{
private readonly IDocFxService _docFxService;
public DocumentationGenerator(IDocFxService docFxService)
{
_docFxService = docFxService ?? throw new ArgumentNullException(nameof(docFxService));
}
public async Task<DocumentationModel> GenerateDocumentation(IEnumerable<AssemblyModel> assemblies, ExportSettings settings)
{
try
{
// Generate metadata with DocFX
var metadataPath = await _docFxService.GenerateMetadataAsync(assemblies);
// Process metadata files
var documentation = new DocumentationModel();
var namespaces = new Dictionary<string, NamespaceDocumentation>();
// Read YAML files produced by DocFX
var ymlFiles = Directory.GetFiles(metadataPath, "*.yml", SearchOption.AllDirectories);
foreach (var ymlFile in ymlFiles)
{
ProcessYamlMetadata(ymlFile, documentation, namespaces, settings);
}
return documentation;
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al generar documentación: {ex.Message}", ex);
}
}
private void ProcessYamlMetadata(string ymlFile, DocumentationModel documentation,
Dictionary<string, NamespaceDocumentation> namespaces,
ExportSettings settings)
{
// This is a simplified implementation. In a real application,
// you would need to use a YAML parser to read DocFX output
// For this example, we'll create sample documentation data
var typeDoc = new TypeDocumentation
{
Name = Path.GetFileNameWithoutExtension(ymlFile),
FullName = $"ExampleNamespace.{Path.GetFileNameWithoutExtension(ymlFile)}",
Description = "Descripción del tipo extraída de comentarios XML",
TypeKind = "Class"
};
// Add some members
typeDoc.Members.Add(new MemberDocumentation
{
Name = "ExampleMethod",
Description = "Un método de ejemplo con documentación",
MemberType = "Method",
Signature = "public void ExampleMethod(string parameter1, int parameter2)",
ReturnType = "void",
ReturnDescription = "Este método no devuelve ningún valor"
});
// Add parameters to the method
typeDoc.Members[0].Parameters.Add(new ParameterDocumentation
{
Name = "parameter1",
Type = "string",
Description = "Descripción del primer parámetro"
});
typeDoc.Members[0].Parameters.Add(new ParameterDocumentation
{
Name = "parameter2",
Type = "int",
Description = "Descripción del segundo parámetro"
});
// Add to namespace
var namespaceName = "ExampleNamespace";
if (!namespaces.TryGetValue(namespaceName, out var namespaceDoc))
{
namespaceDoc = new NamespaceDocumentation
{
Name = namespaceName,
Description = "Descripción del namespace"
};
namespaces[namespaceName] = namespaceDoc;
documentation.Namespaces.Add(namespaceDoc);
}
namespaceDoc.Types.Add(typeDoc);
}
public string GenerateDocumentationPreview(DocumentationModel documentation, ExportSettings settings)
{
try
{
if (settings.OutputFormat == OutputFormat.Json)
{
return JsonConvert.SerializeObject(documentation, Formatting.Indented,
new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
else // YAML
{
// Convert to JSON first, then to YAML (simplified)
var json = JsonConvert.SerializeObject(documentation, Formatting.None,
new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
// In a real application, you would use a YAML serializer
// For this example, we'll return a simple YAML representation
return ConvertJsonToSimpleYaml(json);
}
}
catch (Exception ex)
{
throw new InvalidOperationException($"Error al generar vista previa: {ex.Message}", ex);
}
}
private string ConvertJsonToSimpleYaml(string json)
{
// This is a simplified conversion for demonstration purposes
// In a real application, you would use a YAML serializer library
// Deserialize JSON
var obj = JsonConvert.DeserializeObject<dynamic>(json);
// Basic YAML builder
var yaml = new System.Text.StringBuilder();
yaml.AppendLine("namespaces:");
foreach (var ns in obj.Namespaces)
{
yaml.AppendLine($" - name: {ns.Name}");
yaml.AppendLine($" description: {ns.Description}");
yaml.AppendLine(" types:");
foreach (var type in ns.Types)
{
yaml.AppendLine($" - name: {type.Name}");
yaml.AppendLine($" fullName: {type.FullName}");
yaml.AppendLine($" typeKind: {type.TypeKind}");
yaml.AppendLine($" description: {type.Description}");
yaml.AppendLine(" members:");
foreach (var member in type.Members)
{
yaml.AppendLine($" - name: {member.Name}");
yaml.AppendLine($" memberType: {member.MemberType}");
yaml.AppendLine($" signature: {member.Signature}");
yaml.AppendLine($" description: {member.Description}");
if (member.Parameters.Count > 0)
{
yaml.AppendLine(" parameters:");
foreach (var param in member.Parameters)
{
yaml.AppendLine($" - name: {param.Name}");
yaml.AppendLine($" type: {param.Type}");
yaml.AppendLine($" description: {param.Description}");
}
}
if (!string.IsNullOrEmpty(member.ReturnType))
{
yaml.AppendLine($" returnType: {member.ReturnType}");
yaml.AppendLine($" returnDescription: {member.ReturnDescription}");
}
}
}
}
return yaml.ToString();
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetDocsForLLM.ViewModels
{
class DocumentationViewModel
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetDocsForLLM.ViewModels
{
class ExportViewModel
{
}
}

245
ViewModels/MainViewModel.cs Normal file
View File

@ -0,0 +1,245 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NetDocsForLLM.Models;
using NetDocsForLLM.Services;
using Ookii.Dialogs.Wpf;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
namespace NetDocsForLLM.ViewModels
{
public class MainViewModel : ObservableObject
{
private readonly IAssemblyAnalyzer _assemblyAnalyzer;
private readonly IDocumentationGenerator _documentationGenerator;
private ObservableCollection<AssemblyModel> _selectedAssemblies;
private DocumentationModel _documentationModel;
private ExportSettings _settings;
private string _documentationPreview;
private string _documentationStats;
private string _statusMessage;
private bool _isProcessing;
private bool _hasGeneratedDocumentation;
public ObservableCollection<AssemblyModel> SelectedAssemblies
{
get => _selectedAssemblies;
set => SetProperty(ref _selectedAssemblies, value);
}
public DocumentationModel DocumentationModel
{
get => _documentationModel;
set => SetProperty(ref _documentationModel, value);
}
public ExportSettings Settings
{
get => _settings;
set => SetProperty(ref _settings, value);
}
public string DocumentationPreview
{
get => _documentationPreview;
set => SetProperty(ref _documentationPreview, value);
}
public string DocumentationStats
{
get => _documentationStats;
set => SetProperty(ref _documentationStats, value);
}
public string StatusMessage
{
get => _statusMessage;
set => SetProperty(ref _statusMessage, value);
}
public bool IsProcessing
{
get => _isProcessing;
set => SetProperty(ref _isProcessing, value);
}
public bool HasGeneratedDocumentation
{
get => _hasGeneratedDocumentation;
set => SetProperty(ref _hasGeneratedDocumentation, value);
}
public bool HasSelectedAssemblies => SelectedAssemblies.Count > 0;
public IRelayCommand SelectAssembliesCommand { get; }
public IRelayCommand<AssemblyModel> RemoveAssemblyCommand { get; }
public IRelayCommand GenerateDocumentationCommand { get; }
public IRelayCommand CopyToClipboardCommand { get; }
public IRelayCommand ExportDocumentationCommand { get; }
public MainViewModel(IAssemblyAnalyzer assemblyAnalyzer, IDocumentationGenerator documentationGenerator)
{
_assemblyAnalyzer = assemblyAnalyzer ?? throw new ArgumentNullException(nameof(assemblyAnalyzer));
_documentationGenerator = documentationGenerator ?? throw new ArgumentNullException(nameof(documentationGenerator));
_selectedAssemblies = new ObservableCollection<AssemblyModel>();
_documentationModel = new DocumentationModel();
_settings = new ExportSettings();
_documentationPreview = string.Empty;
_documentationStats = string.Empty;
_statusMessage = "Listo";
_isProcessing = false;
_hasGeneratedDocumentation = false;
SelectAssembliesCommand = new RelayCommand(SelectAssemblies);
RemoveAssemblyCommand = new RelayCommand<AssemblyModel>(RemoveAssembly);
GenerateDocumentationCommand = new AsyncRelayCommand(GenerateDocumentationAsync);
CopyToClipboardCommand = new RelayCommand(CopyToClipboard, () => HasGeneratedDocumentation);
ExportDocumentationCommand = new RelayCommand(ExportDocumentation, () => HasGeneratedDocumentation);
// Subscribe to collection changes to update HasSelectedAssemblies
_selectedAssemblies.CollectionChanged += (sender, e) =>
{
OnPropertyChanged(nameof(HasSelectedAssemblies));
};
}
private void SelectAssemblies()
{
var dialog = new VistaOpenFileDialog
{
Filter = "Ensamblados .NET (*.dll)|*.dll",
Multiselect = true,
Title = "Seleccionar librerías .NET"
};
if (dialog.ShowDialog() == true)
{
foreach (var filePath in dialog.FileNames)
{
try
{
// Check if the assembly is already selected
if (_selectedAssemblies.Count(a => a.FilePath == filePath) > 0)
continue;
var assembly = _assemblyAnalyzer.LoadAssembly(filePath);
if (assembly != null)
{
SelectedAssemblies.Add(assembly);
StatusMessage = $"Librería cargada: {assembly.Name}";
}
}
catch (Exception ex)
{
MessageBox.Show($"Error al cargar el ensamblado: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
private void RemoveAssembly(AssemblyModel assembly)
{
if (assembly != null)
{
SelectedAssemblies.Remove(assembly);
StatusMessage = $"Librería removida: {assembly.Name}";
}
}
private async Task GenerateDocumentationAsync()
{
if (SelectedAssemblies.Count == 0)
{
MessageBox.Show("Por favor, seleccione al menos una librería para generar documentación.",
"Sin librerías", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
try
{
IsProcessing = true;
StatusMessage = "Generando documentación...";
// Generate documentation
DocumentationModel = await Task.Run(() =>
_documentationGenerator.GenerateDocumentation(SelectedAssemblies, Settings));
// Generate preview
DocumentationPreview = await Task.Run(() =>
_documentationGenerator.GenerateDocumentationPreview(DocumentationModel, Settings));
// Update stats
var totalTypes = DocumentationModel.Namespaces.Sum(n => n.Types.Count);
var totalMembers = DocumentationModel.Namespaces.Sum(n =>
n.Types.Sum(t => t.Members.Count));
DocumentationStats = $"Resumen: {DocumentationModel.Namespaces.Count} namespaces, " +
$"{totalTypes} tipos, {totalMembers} miembros";
HasGeneratedDocumentation = true;
StatusMessage = "Documentación generada correctamente";
}
catch (Exception ex)
{
MessageBox.Show($"Error al generar la documentación: {ex.Message}",
"Error", MessageBoxButton.OK, MessageBoxImage.Error);
StatusMessage = "Error al generar documentación";
}
finally
{
IsProcessing = false;
}
}
private void CopyToClipboard()
{
if (string.IsNullOrEmpty(DocumentationPreview))
return;
try
{
Clipboard.SetText(DocumentationPreview);
StatusMessage = "Documentación copiada al portapapeles";
}
catch (Exception ex)
{
MessageBox.Show($"Error al copiar al portapapeles: {ex.Message}",
"Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void ExportDocumentation()
{
if (string.IsNullOrEmpty(DocumentationPreview))
return;
var dialog = new VistaSaveFileDialog
{
Filter = Settings.OutputFormat == OutputFormat.Json
? "Archivos JSON (*.json)|*.json"
: "Archivos YAML (*.yaml;*.yml)|*.yaml;*.yml",
DefaultExt = Settings.OutputFormat == OutputFormat.Json ? ".json" : ".yaml",
Title = "Guardar documentación"
};
if (dialog.ShowDialog() == true)
{
try
{
File.WriteAllText(dialog.FileName, DocumentationPreview);
StatusMessage = $"Documentación guardada en: {dialog.FileName}";
}
catch (Exception ex)
{
MessageBox.Show($"Error al guardar el archivo: {ex.Message}",
"Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
<Window x:Class="NetDocsForLLM.Views.DocumentationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NetDocsForLLM.Views"
mc:Ignorable="d"
Title="DocumentationView" Height="450" Width="800">
<Grid>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace NetDocsForLLM.Views
{
/// <summary>
/// Interaction logic for DocumentationView.xaml
/// </summary>
public partial class DocumentationView : Window
{
public DocumentationView()
{
InitializeComponent();
}
}
}

12
Views/ExportView.xaml Normal file
View File

@ -0,0 +1,12 @@
<Window x:Class="NetDocsForLLM.Views.ExportView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NetDocsForLLM.Views"
mc:Ignorable="d"
Title="ExportView" Height="450" Width="800">
<Grid>
</Grid>
</Window>

27
Views/ExportView.xaml.cs Normal file
View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace NetDocsForLLM.Views
{
/// <summary>
/// Interaction logic for ExportView.xaml
/// </summary>
public partial class ExportView : Window
{
public ExportView()
{
InitializeComponent();
}
}
}