You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.179
Former-commit-id: a536d4f20e27294d8bbc2184d75f3a22364f7ba1
This commit is contained in:
parent
966bba02bb
commit
fad71374d0
12
external/api-doc-tools/.gitignore
vendored
Normal file
12
external/api-doc-tools/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/Test/en.*/
|
||||
/Test/html.*/
|
||||
/Test/DocTest.*
|
||||
/.v2.txt
|
||||
/.v0.txt
|
||||
packages
|
||||
NUnit.*
|
||||
TestResult.xml
|
||||
*.userprefs
|
||||
*.user
|
||||
bin
|
||||
obj
|
6
external/api-doc-tools/.gitmodules
vendored
Normal file
6
external/api-doc-tools/.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "external/SharpZipLib"]
|
||||
path = external/SharpZipLib
|
||||
url = https://github.com/icsharpcode/SharpZipLib.git
|
||||
[submodule "external/Lucene.Net.Light"]
|
||||
path = external/Lucene.Net.Light
|
||||
url = https://github.com/mono/Lucene.Net.Light.git
|
27
external/api-doc-tools/Makefile
vendored
Normal file
27
external/api-doc-tools/Makefile
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
MSBUILD = msbuild
|
||||
CONFIGURATION = Release
|
||||
BIN = bin/$(CONFIGURATION)
|
||||
MDOC = $(BIN)/mdoc.exe
|
||||
|
||||
all: build
|
||||
|
||||
build: $(MDOC)
|
||||
|
||||
$(MDOC):
|
||||
$(MSBUILD) apidoctools.sln /p:Configuration=$(CONFIGURATION)
|
||||
|
||||
prepare:
|
||||
git submodule update --init --recursive
|
||||
nuget restore apidoctools.sln
|
||||
|
||||
clean:
|
||||
$(MSBUILD) apidoctools.sln /t:clean
|
||||
rm -rf bin/$(CONFIGURATION)
|
||||
|
||||
check: build check-monodoc check-mdoc
|
||||
|
||||
check-mdoc:
|
||||
cd mdoc; $(MAKE) check
|
||||
|
||||
check-monodoc:
|
||||
cd monodoc; $(MAKE) check
|
22
external/api-doc-tools/README.md
vendored
Normal file
22
external/api-doc-tools/README.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# `mdoc` and `monodoc`
|
||||
|
||||
This repository contains the source for Mono's [documentation toolchain](http://www.mono-project.com/docs/tools+libraries/tools/monodoc/generating-documentation/).
|
||||
|
||||
## Compiling
|
||||
|
||||
### CLI
|
||||
If you've got `make` installed, you can run `make prepare all check`. The available targets are:
|
||||
|
||||
- `prepare`: initializes the submodules, and restores the nuget dependency of NUnit
|
||||
- `all`: compiles everything
|
||||
- `check`: runs unit tests for _monodoc_ and _mdoc_
|
||||
- `check-mdoc`: runs only _mdoc_ tests
|
||||
- `check-monodoc`: runs only _monodoc_ tests
|
||||
|
||||
You can also control some parameters from the command line:
|
||||
|
||||
If you want to compile in debug mode: `make all CONFIGURATION=Debug`
|
||||
|
||||
### Visual Studio
|
||||
Once you run `make prepare all` at least once (to restore submodules), you can open the solution in
|
||||
_Visual Studio_ to compile and debug.
|
61
external/api-doc-tools/apidoctools.sln
vendored
Normal file
61
external/api-doc-tools/apidoctools.sln
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26206.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mdoc", "mdoc\mdoc.csproj", "{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "monodoc", "monodoc\monodoc.csproj", "{6E644802-B579-4037-9809-9CF4C7172C9D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monodoc.Test", "monodoc\Test\Monodoc.Test.csproj", "{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpZipLib", "external\SharpZipLib\ICSharpCode.SharpZipLib.NET45\ICSharpCode.SharpZipLib.csproj", "{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7DA7CD97-614F-4BCD-A2FA-B379590CEA48}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6E644802-B579-4037-9809-9CF4C7172C9D}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = mdoc.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
external/api-doc-tools/mdoc/.gitignore
vendored
Normal file
7
external/api-doc-tools/mdoc/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/Test/en.*/
|
||||
/Test/html.*/
|
||||
/Test/DocTest.*
|
||||
/Test/*.dll*
|
||||
/Test/FrameworkTestData*
|
||||
/.v2.txt
|
||||
/.v0.txt
|
8
external/api-doc-tools/mdoc/Consts.cs
vendored
Normal file
8
external/api-doc-tools/mdoc/Consts.cs
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
public static class Consts
|
||||
{
|
||||
public static string MonoVersion = "5.0.0.14";
|
||||
}
|
||||
}
|
463
external/api-doc-tools/mdoc/Makefile
vendored
Normal file
463
external/api-doc-tools/mdoc/Makefile
vendored
Normal file
@@ -0,0 +1,463 @@
|
||||
CONFIGURATION = Release
|
||||
PROGRAM = ../bin/$(CONFIGURATION)/mdoc.exe
|
||||
MONO = mono
|
||||
CSCOMPILE = mcs
|
||||
TEST_CSCFLAGS = -target:library
|
||||
|
||||
MDOC_COMMON_FLAGS = \
|
||||
/resource:../../class/monodoc/Resources/mdoc-html-format.xsl,mdoc-html-format.xsl \
|
||||
/resource:../../class/monodoc/Resources/mdoc-html-utils.xsl,mdoc-html-utils.xsl \
|
||||
/resource:../../class/monodoc/Resources/mdoc-sections-css.xsl,mdoc-sections-css.xsl \
|
||||
/resource:../../class/monodoc/Resources/mono-ecma-css.xsl,mono-ecma-css.xsl \
|
||||
/resource:Resources/defaulttemplate.xsl,defaulttemplate.xsl \
|
||||
/resource:Resources/monodoc-ecma.xsd,monodoc-ecma.xsd \
|
||||
/resource:Resources/msitomsx.xsl,msitomsx.xsl \
|
||||
/resource:Resources/overview.xsl,overview.xsl \
|
||||
/resource:Resources/stylesheet.xsl,stylesheet.xsl \
|
||||
|
||||
|
||||
MONODOC_RESOURCES = \
|
||||
../../class/monodoc/Resources/mdoc-html-utils.xsl \
|
||||
../../class/monodoc/Resources/mdoc-sections-css.xsl \
|
||||
../../class/monodoc/Resources/mono-ecma-css.xsl
|
||||
|
||||
MDOC_RESOURCES = \
|
||||
Resources/defaulttemplate.xsl \
|
||||
Resources/monodoc-ecma.xsd \
|
||||
Resources/msitomsx.xsl \
|
||||
Resources/overview.xsl \
|
||||
Resources/stylesheet.xsl
|
||||
|
||||
MDOC_TEST_FILES = \
|
||||
Test/CLILibraryTypes.dtd \
|
||||
Test/DocTest-v1.cs \
|
||||
Test/DocTest-v2.patch \
|
||||
Test/msxdoc-expected.importslashdoc.xml \
|
||||
Test/TestEcmaDocs.xml \
|
||||
Test/validate.check.monodocer \
|
||||
Test/validate.check.monodocer.importslashdoc \
|
||||
Test/validate.check.monodocer.since
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
$(MDOC_RESOURCES) \
|
||||
$(MDOC_TEST_FILES)
|
||||
|
||||
MULTI-CLASSIC = Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-multitest.dll
|
||||
MULTI-UNIFIED = Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-unified-multitest.dll
|
||||
|
||||
DIFF = diff -rup
|
||||
DIFF_QUIET = diff --brief
|
||||
ifeq ($(PLATFORM), win32)
|
||||
DIFF = diff -rupZ
|
||||
DIFF_QUIET = diff --brief -Z
|
||||
endif
|
||||
|
||||
cleanup:
|
||||
-rm -Rf Test/en.actual Test/html.actual
|
||||
|
||||
Test/DocTest-addNonGeneric.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-addNonGeneric.cs
|
||||
|
||||
Test/DocTest-addNonGeneric-v2.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-addNonGeneric.cs /define:V2
|
||||
|
||||
Test/DocTest-DropNS-classic-secondary.dll:
|
||||
@echo $(value @)
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic-secondary.cs
|
||||
|
||||
Test/DocTest-DropNS-classic.dll:
|
||||
@echo $(value @)
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic.cs
|
||||
|
||||
Test/DocTest-DropNS-unified.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-unified.cs
|
||||
|
||||
Test/DocTest-DropNS-unified-multitest.dll:
|
||||
rm -f $@
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-unified.cs /define:MULTITEST
|
||||
|
||||
Test/DocTest-DropNS-classic-multitest.dll:
|
||||
rm -f $@
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic.cs /define:MULTITEST
|
||||
|
||||
Test/DocTest-DropNS-unified-deletetest.dll:
|
||||
rm -f Test/DocTest-DropNS-unified-deletetest.dll
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-unified.cs /define:DELETETEST
|
||||
|
||||
Test/DocTest-DropNS-unified-deletetest-V2.dll:
|
||||
rm -f Test/DocTest-DropNS-unified-deletetest.dll
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:Test/DocTest-DropNS-unified-deletetest.dll Test/DocTest-DropNS-unified.cs /define:DELETETEST,V2
|
||||
|
||||
Test/DocTest-DropNS-classic-deletetest.dll:
|
||||
rm -f Test/DocTest-DropNS-classic-deletetest.dll
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-DropNS-classic.cs /define:DELETETEST
|
||||
|
||||
Test/DocTest-DropNS-classic-deletetest-V2.dll:
|
||||
rm -f Test/DocTest-DropNS-classic-deletetest.dll
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:Test/DocTest-DropNS-classic-deletetest.dll Test/DocTest-DropNS-classic.cs /define:DELETETEST,V2
|
||||
|
||||
Test/DocTest.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -debug -optimize -unsafe -target:library -out:$@ Test/DocTest.cs -r:System.Core.dll -r:Microsoft.CSharp.dll
|
||||
|
||||
Test/DocTest-InternalInterface.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-InternalInterface.cs
|
||||
|
||||
Test/DocTest-framework-inheritance-one.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-framework-inheritance.cs /define:FXONE
|
||||
|
||||
Test/DocTest-framework-inheritance-two.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-framework-inheritance.cs /define:FXTWO
|
||||
|
||||
Test/DocTest.dll-v1:
|
||||
-rm -f Test/DocTest.cs
|
||||
cp Test/DocTest-v1.cs Test/DocTest.cs
|
||||
-rm -f Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll
|
||||
|
||||
Test/DocTest.dll-v2:
|
||||
-rm -f Test/DocTest.cs
|
||||
cp Test/DocTest-v1.cs Test/DocTest.cs
|
||||
cd Test && patch -p0 < DocTest-v2.patch
|
||||
-rm -f Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll
|
||||
|
||||
Test/DocTest-enumerations.dll:
|
||||
$(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-enumerations.cs
|
||||
|
||||
Test/FrameworkTestData: Test/DocTest-addNonGeneric.dll Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll
|
||||
rm -rf Test/FrameworkTestData
|
||||
mkdir Test/FrameworkTestData
|
||||
mkdir Test/FrameworkTestData/One
|
||||
mkdir Test/FrameworkTestData/Two
|
||||
cp Test/DocTest-addNonGeneric.dll Test/FrameworkTestData/One/
|
||||
cp Test/DocTest-DropNS-classic.dll Test/FrameworkTestData/One/
|
||||
cp Test/DocTest-addNonGeneric.dll Test/FrameworkTestData/Two/
|
||||
cp Test/DocTest-DropNS-classic-secondary.dll Test/FrameworkTestData/Two/
|
||||
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData
|
||||
|
||||
Test/FrameworkTestData-fx-inheritance: Test/DocTest-framework-inheritance-one.dll Test/DocTest-framework-inheritance-two.dll
|
||||
rm -rf Test/FrameworkTestData-fx-inheritance
|
||||
mkdir Test/FrameworkTestData-fx-inheritance
|
||||
mkdir Test/FrameworkTestData-fx-inheritance/One
|
||||
mkdir Test/FrameworkTestData-fx-inheritance/Two
|
||||
cp Test/DocTest-framework-inheritance-one.dll Test/FrameworkTestData-fx-inheritance/One/
|
||||
cp Test/DocTest-framework-inheritance-two.dll Test/FrameworkTestData-fx-inheritance/Two/
|
||||
$(MONO) $(PROGRAM) fx-bootstrap Test/FrameworkTestData-fx-inheritance
|
||||
|
||||
check-monodocer-frameworks: Test/FrameworkTestData
|
||||
-rm -Rf Test/en.actual
|
||||
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData
|
||||
$(DIFF) Test/en.expected-frameworks Test/en.actual
|
||||
|
||||
check-monodocer-frameworks-inheritance: Test/FrameworkTestData-fx-inheritance
|
||||
-rm -Rf Test/en.actual
|
||||
$(MONO) $(PROGRAM) update -o Test/en.actual -frameworks Test/FrameworkTestData-fx-inheritance
|
||||
$(DIFF) Test/en.expected-frameworks-inheritance Test/en.actual
|
||||
|
||||
check-monodocer-docid: Test/FrameworkTestData
|
||||
-rm -Rf Test/en.actual
|
||||
$(MONO) $(PROGRAM) update -use-docid -o Test/en.actual -frameworks Test/FrameworkTestData
|
||||
$(DIFF) Test/en.expected-docid Test/en.actual
|
||||
|
||||
check-monodocer-addNonGeneric:
|
||||
-rm -Rf Test/en.actual
|
||||
# first, make a docset with the generic method
|
||||
$(MAKE) Test/DocTest-addNonGeneric.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric.dll
|
||||
|
||||
# now add a non-generic version of the method and update several times
|
||||
$(MAKE) Test/DocTest-addNonGeneric-v2.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
|
||||
$(DIFF) Test/en.expected-addNonGeneric Test/en.actual
|
||||
|
||||
check-monodocer-membergroup: Test/DocTest-addNonGeneric-v2.dll Test/DocTest-addNonGeneric.dll
|
||||
-rm -Rf Test/en.actual
|
||||
cp -r Test/en.expected-membergroup Test/en.actual
|
||||
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
|
||||
$(DIFF) Test/en.expected-membergroup Test/en.actual
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.actual
|
||||
|
||||
check-monodocer-dropns-classic:
|
||||
# tests the simplest --dropns case, a single class where the root namespace was dropped.
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-DropNS-classic.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
|
||||
$(MAKE) update-monodocer-dropns-unified
|
||||
$(DIFF) Test/en.expected-dropns-classic-v1 Test/en.actual
|
||||
|
||||
check-monodocer-dropns-multi:
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-DropNS-classic.dll
|
||||
$(MAKE) Test/DocTest-DropNS-unified.dll
|
||||
$(MAKE) Test/DocTest-DropNS-classic-multitest.dll
|
||||
$(MAKE) Test/DocTest-DropNS-unified-multitest.dll
|
||||
|
||||
# mdoc update for both classic and unified
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
|
||||
|
||||
# now run it again to verify idempotency
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
|
||||
|
||||
$(DIFF) Test/en.expected-dropns-multi Test/en.actual
|
||||
|
||||
|
||||
check-monodocer-dropns-multi-withexisting:
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-DropNS-classic.dll
|
||||
$(MAKE) Test/DocTest-DropNS-unified.dll
|
||||
$(MAKE) Test/DocTest-DropNS-classic-multitest.dll
|
||||
$(MAKE) Test/DocTest-DropNS-unified-multitest.dll
|
||||
|
||||
# mdoc update to show a pre-existing set of documents
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
|
||||
|
||||
# mdoc update for both classic and unified
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework
|
||||
|
||||
$(DIFF) Test/en.expected-dropns-multi-withexisting Test/en.actual
|
||||
|
||||
check-monodocer-dropns-delete:
|
||||
-rm -Rf Test/en.actual
|
||||
rm -Rf Test/DocTest-DropNS-classic-deletetest.dll
|
||||
rm -Rf Test/DocTest-DropNS-unified-deletetest.dll
|
||||
$(MAKE) Test/DocTest-DropNS-classic-deletetest.dll
|
||||
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
|
||||
$(MAKE) Test/DocTest-DropNS-unified-deletetest.dll
|
||||
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework
|
||||
$(MAKE) Test/DocTest-DropNS-classic-deletetest-V2.dll
|
||||
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic
|
||||
$(MAKE) Test/DocTest-DropNS-unified-deletetest-V2.dll
|
||||
$(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework
|
||||
$(DIFF) Test/en.expected-dropns-delete Test/en.actual
|
||||
|
||||
check-monodocer-dropns-classic-withsecondary:
|
||||
# tests case where a secondary assembly is included with a --dropns parameter
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-DropNS-classic.dll
|
||||
$(MAKE) Test/DocTest-DropNS-classic-secondary.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
|
||||
$(MAKE) update-monodocer-dropns-unified-withsecondary
|
||||
$(DIFF) Test/en.expected-dropns-classic-withsecondary Test/en.actual
|
||||
|
||||
update-monodocer-dropns-unified:
|
||||
$(MAKE) Test/DocTest-DropNS-unified.dll
|
||||
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
|
||||
|
||||
update-monodocer-dropns-unified-withsecondary:
|
||||
$(MAKE) Test/DocTest-DropNS-unified.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework
|
||||
|
||||
update-monodocer-dropns-classic-secondary:
|
||||
$(MAKE) Test/DocTest-DropNS-classic-secondary.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll --api-style=classic
|
||||
|
||||
check-monodocer-internal-interface:
|
||||
# Tests to make sure internal interfaces that are explicitly implemented are not documented
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-InternalInterface.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-InternalInterface.dll
|
||||
$(DIFF) Test/en.expected-internal-interface Test/en.actual
|
||||
|
||||
check-monodocer-enumerations:
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest-enumerations.dll
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-enumerations.dll
|
||||
$(DIFF) Test/en.expected-enumerations Test/en.actual
|
||||
|
||||
check-monodocer-update:
|
||||
find Test/en.expected -name \*.xml -exec rm "{}" \;
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected Test/DocTest.dll
|
||||
|
||||
check-monodocer:
|
||||
-rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected Test/en.actual
|
||||
$(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected Test/en.actual
|
||||
|
||||
check-monodocer-since-update:
|
||||
find Test/en.expected.since -name \*.xml -exec rm "{}" \;
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.since Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v2
|
||||
$(MONO) $(PROGRAM) update --exceptions=all --since="Version 2.0" \
|
||||
-o Test/en.expected.since Test/DocTest.dll
|
||||
|
||||
check-monodocer-since:
|
||||
rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v2
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all --since="Version 2.0" \
|
||||
-o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected.since Test/en.actual
|
||||
|
||||
check-monodocer-delete-update:
|
||||
find Test/en.expected.delete -type f -exec rm "{}" \;
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.delete Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v2
|
||||
$(MONO) $(PROGRAM) update --exceptions=all -o Test/en.expected.delete Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) update -fno-assembly-versions --delete --exceptions=all \
|
||||
-o Test/en.expected.delete Test/DocTest.dll
|
||||
|
||||
check-monodocer-delete:
|
||||
rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v2
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) --debug update -fno-assembly-versions --delete --exceptions=all -o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected.delete Test/en.actual
|
||||
|
||||
check-monodocer-ignore-invalid-assemblies: Test/DocTest-addNonGeneric.dll Test/DocTest-addNonGeneric-v2.dll
|
||||
-rm -Rf Test/en.actual
|
||||
touch Test/notActuallyA.dll
|
||||
$(MONO) $(PROGRAM) --debug update -o Test/en.actual Test/DocTest-addNonGeneric.dll Test/notActuallyA.dll
|
||||
$(MONO) $(PROGRAM) --debug update -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll Test/notActuallyA.dll
|
||||
$(DIFF) Test/en.expected-addNonGeneric Test/en.actual
|
||||
|
||||
check-monodocer-importslashdoc-update:
|
||||
find Test/en.expected.importslashdoc -name \*.xml -exec rm "{}" \;
|
||||
$(MAKE) Test/DocTest.dll-v1 TEST_CSCFLAGS=-doc:Test/DocTest.xml
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/DocTest.xml \
|
||||
-o Test/en.expected.importslashdoc Test/DocTest.dll
|
||||
|
||||
check-monodocer-importslashdoc:
|
||||
rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest.dll-v1 TEST_CSCFLAGS=-doc:Test/DocTest.xml
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/DocTest.xml \
|
||||
-o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected.importslashdoc Test/en.actual
|
||||
|
||||
check-monodocer-importecmadoc-update:
|
||||
find Test/en.expected.importecmadoc -name \*.xml -exec rm "{}" \;
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/TestEcmaDocs.xml \
|
||||
'--type=System.Action`1' --type=System.AsyncCallback \
|
||||
--type=System.Environment --type=System.Array \
|
||||
-o Test/en.expected.importecmadoc Test/DocTest.dll
|
||||
|
||||
check-monodocer-importecmadoc:
|
||||
rm -Rf Test/en.actual
|
||||
$(MAKE) Test/DocTest.dll-v1
|
||||
$(MONO) $(PROGRAM) --debug update --exceptions=all -i Test/TestEcmaDocs.xml \
|
||||
'--type=System.Action`1' --type=System.AsyncCallback \
|
||||
--type=System.Environment --type=System.Array \
|
||||
-o Test/en.actual Test/DocTest.dll
|
||||
$(DIFF) Test/en.expected.importecmadoc Test/en.actual
|
||||
|
||||
check-mdoc-export-html-update:
|
||||
find Test/html.expected -name \*.html -exec rm "{}" \;
|
||||
$(MONO) $(PROGRAM) export-html -o Test/html.expected \
|
||||
Test/en.expected.importslashdoc
|
||||
|
||||
check-mdoc-export-html-with-array-extension:
|
||||
rm -Rf Test/html.actual
|
||||
$(MAKE) check-monodocer
|
||||
$(MONO) $(PROGRAM) export-html -o Test/html.actual \
|
||||
Test/en.actual
|
||||
$(DIFF) Test/html.expected-with-array-extension Test/html.actual
|
||||
|
||||
check-mdoc-export-html: check-monodocer
|
||||
rm -Rf Test/html.actual
|
||||
$(MONO) $(PROGRAM) export-html -o Test/html.actual \
|
||||
Test/en.expected.importslashdoc
|
||||
$(DIFF) Test/html.expected Test/html.actual
|
||||
|
||||
check-mdoc-export-html-with-version:
|
||||
rm -Rf Test/html.actual.v0 Test/html.actual.since-with-v0 .v0.txt .v2.txt
|
||||
$(MONO) $(PROGRAM) export-html -o Test/html.actual.v0 \
|
||||
Test/en.expected
|
||||
$(MONO) $(PROGRAM) export-html -o Test/html.actual.since-with-v0 \
|
||||
Test/en.expected.since -with-version 0.0.0.0
|
||||
(cd Test/html.actual.v0 && find . -type f) | sort > .v0.txt
|
||||
(cd Test/html.actual.since-with-v0 && find . -type f) | sort > .v2.txt
|
||||
$(DIFF) .v0.txt .v2.txt # assert no types added
|
||||
|
||||
check-md-html-dir:
|
||||
rm -Rf Test/html.actual
|
||||
$(MONO) $(PROGRAM) export-html -dest:Test/html.actual $(DIR)
|
||||
$(DIFF) Test/html.expected Test/html.actual
|
||||
|
||||
check-mdoc-export-msxdoc-update:
|
||||
$(MONO) $(PROGRAM) export-msxdoc -o - Test/en.expected.importslashdoc \
|
||||
> Test/msxdoc-expected.importslashdoc.xml
|
||||
|
||||
check-mdoc-export-msxdoc:
|
||||
$(MONO) $(PROGRAM) export-msxdoc -o - Test/en.expected.importslashdoc \
|
||||
| $(DIFF_QUIET) - Test/msxdoc-expected.importslashdoc.xml
|
||||
|
||||
my_abs_top_srcdir = $(shell cd . && pwd)
|
||||
|
||||
check-mdoc-validate-update:
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' > \
|
||||
Test/validate.check.monodocer
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected.importslashdoc 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' > \
|
||||
Test/validate.check.monodocer.importslashdoc
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected.since 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' > \
|
||||
Test/validate.check.monodocer.since
|
||||
|
||||
check-mdoc-validate:
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' | \
|
||||
$(DIFF_QUIET) - Test/validate.check.monodocer
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected.importslashdoc 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' | \
|
||||
$(DIFF_QUIET) - Test/validate.check.monodocer.importslashdoc
|
||||
$(MONO) $(PROGRAM) validate -f ecma Test/en.expected.since 2>&1 | \
|
||||
sed 's#file://$(my_abs_top_srcdir)/##g' | \
|
||||
$(DIFF_QUIET) - Test/validate.check.monodocer.since
|
||||
|
||||
run-test-local: check-doc-tools
|
||||
|
||||
run-test-update : check-doc-tools-update
|
||||
|
||||
check-doc-tools: check-monodocer-since \
|
||||
check-monodocer-importecmadoc \
|
||||
check-monodocer-importslashdoc \
|
||||
check-monodocer \
|
||||
check-monodocer-delete \
|
||||
check-mdoc-export-html \
|
||||
check-mdoc-export-html-with-version \
|
||||
check-mdoc-export-html-with-array-extension \
|
||||
check-mdoc-export-msxdoc \
|
||||
check-mdoc-validate \
|
||||
check-monodocer-dropns-classic \
|
||||
check-monodocer-dropns-classic-withsecondary \
|
||||
check-monodocer-dropns-delete \
|
||||
check-monodocer-internal-interface \
|
||||
check-monodocer-addNonGeneric \
|
||||
check-monodocer-membergroup \
|
||||
check-monodocer-ignore-invalid-assemblies \
|
||||
check-monodocer-enumerations \
|
||||
check-monodocer-dropns-multi \
|
||||
check-monodocer-dropns-multi-withexisting \
|
||||
check-monodocer-frameworks \
|
||||
check-monodocer-frameworks-inheritance \
|
||||
check-monodocer-docid
|
||||
|
||||
check-doc-tools-update: check-monodocer-since-update \
|
||||
check-monodocer-importecmadoc-update \
|
||||
check-monodocer-importslashdoc-update \
|
||||
check-monodocer-update \
|
||||
check-monodocer-delete-update \
|
||||
check-mdoc-export-html-update \
|
||||
check-mdoc-export-msxdoc-update \
|
||||
check-mdoc-validate-update
|
||||
|
||||
check: check-doc-tools
|
||||
|
85
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/AssemblySet.cs
vendored
Normal file
85
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/AssemblySet.cs
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a set of assemblies that we want to document
|
||||
/// </summary>
|
||||
class AssemblySet : IDisposable
|
||||
{
|
||||
readonly DefaultAssemblyResolver resolver = new DefaultAssemblyResolver ();
|
||||
HashSet<string> assemblyPaths = new HashSet<string> ();
|
||||
HashSet<string> assemblySearchPaths = new HashSet<string> ();
|
||||
HashSet<string> forwardedTypes = new HashSet<string> ();
|
||||
|
||||
public AssemblySet (string path) : this (new string[] { path }) { }
|
||||
|
||||
public AssemblySet (IEnumerable<string> paths) : this ("Default", paths, new string[0]) { }
|
||||
|
||||
public AssemblySet (string name, IEnumerable<string> paths, IEnumerable<string> resolverSearchPaths)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
foreach (var path in paths)
|
||||
assemblyPaths.Add (path);
|
||||
|
||||
// add default search paths
|
||||
var assemblyDirectories = paths
|
||||
.Where (p => p.Contains (Path.DirectorySeparatorChar))
|
||||
.Select (p => Path.GetDirectoryName (p));
|
||||
|
||||
foreach (var searchPath in resolverSearchPaths.Union(assemblyDirectories))
|
||||
assemblySearchPaths.Add (searchPath);
|
||||
|
||||
char oppositeSeparator = Path.DirectorySeparatorChar == '/' ? '\\' : '/';
|
||||
Func<string, string> sanitize = p =>
|
||||
p.Replace (oppositeSeparator, Path.DirectorySeparatorChar);
|
||||
|
||||
foreach (var searchPath in assemblySearchPaths.Select(sanitize))
|
||||
resolver.AddSearchDirectory (searchPath);
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public IEnumerable<AssemblyDefinition> Assemblies { get { return this.LoadAllAssemblies ().Where(a => a != null); } }
|
||||
public IEnumerable<string> AssemblyPaths { get { return this.assemblyPaths; } }
|
||||
|
||||
/// <returns><c>true</c>, if in set was contained in the set of assemblies, <c>false</c> otherwise.</returns>
|
||||
/// <param name="name">An assembly file name</param>
|
||||
public bool Contains (string name)
|
||||
{
|
||||
return assemblyPaths.Any (p => Path.GetFileName (p) == name);
|
||||
}
|
||||
|
||||
/// <summary>Tells whether an already enumerated AssemblyDefinition, contains the type.</summary>
|
||||
/// <param name="name">Type name</param>
|
||||
public bool ContainsForwardedType (string name)
|
||||
{
|
||||
return forwardedTypes.Contains (name);
|
||||
}
|
||||
|
||||
public void Dispose () => resolver.Dispose ();
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[AssemblySet: Name={0}, Assemblies={1}]", Name, assemblyPaths.Count);
|
||||
}
|
||||
|
||||
IEnumerable<AssemblyDefinition> LoadAllAssemblies ()
|
||||
{
|
||||
foreach (var path in this.assemblyPaths) {
|
||||
var assembly = MDocUpdater.Instance.LoadAssembly (path, this.resolver);
|
||||
if (assembly != null) {
|
||||
foreach (var type in assembly.MainModule.ExportedTypes.Where (t => t.IsForwarder).Select (t => t.FullName))
|
||||
forwardedTypes.Add (type);
|
||||
}
|
||||
yield return assembly;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkEntry.cs
vendored
Normal file
50
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkEntry.cs
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Rocks;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
class FrameworkEntry
|
||||
{
|
||||
SortedSet<FrameworkTypeEntry> types = new SortedSet<FrameworkTypeEntry> ();
|
||||
|
||||
List<FrameworkEntry> allframeworks;
|
||||
|
||||
public FrameworkEntry (List<FrameworkEntry> frameworks)
|
||||
{
|
||||
allframeworks = frameworks;
|
||||
if (allframeworks == null)
|
||||
allframeworks = new List<FrameworkEntry> (0);
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public ISet<FrameworkTypeEntry> Types { get { return this.types; } }
|
||||
|
||||
public IEnumerable<FrameworkEntry> Frameworks { get { return this.allframeworks; } }
|
||||
|
||||
public static readonly FrameworkEntry Empty = new EmptyFrameworkEntry () { Name = "Empty" };
|
||||
|
||||
public virtual FrameworkTypeEntry ProcessType (TypeDefinition type)
|
||||
{
|
||||
|
||||
var entry = types.FirstOrDefault (t => t.Name.Equals (type.FullName));
|
||||
if (entry == null) {
|
||||
var docid = DocCommentId.GetDocCommentId (type);
|
||||
entry = new FrameworkTypeEntry (this) { Id = docid, Name = type.FullName, Namespace = type.Namespace };
|
||||
types.Add (entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
public override string ToString () => this.Name;
|
||||
|
||||
class EmptyFrameworkEntry : FrameworkEntry
|
||||
{
|
||||
public EmptyFrameworkEntry () : base (null) { }
|
||||
public override FrameworkTypeEntry ProcessType (TypeDefinition type) { return FrameworkTypeEntry.Empty; }
|
||||
}
|
||||
}
|
||||
}
|
89
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkIndex.cs
vendored
Normal file
89
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkIndex.cs
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
|
||||
class FrameworkIndex
|
||||
{
|
||||
List<FrameworkEntry> frameworks = new List<FrameworkEntry> ();
|
||||
string path;
|
||||
|
||||
public FrameworkIndex (string pathToFrameworks)
|
||||
{
|
||||
path = pathToFrameworks;
|
||||
}
|
||||
|
||||
public IList<FrameworkEntry> Frameworks {
|
||||
get {
|
||||
return this.frameworks;
|
||||
}
|
||||
}
|
||||
|
||||
public FrameworkEntry StartProcessingAssembly (AssemblyDefinition assembly)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace (this.path))
|
||||
return FrameworkEntry.Empty;
|
||||
|
||||
string assemblyPath = assembly.MainModule.FileName;
|
||||
string relativePath = assemblyPath.Replace (this.path, string.Empty);
|
||||
string shortPath = Path.GetDirectoryName (relativePath);
|
||||
if (shortPath.StartsWith (Path.DirectorySeparatorChar.ToString (), StringComparison.InvariantCultureIgnoreCase))
|
||||
shortPath = shortPath.Substring (1, shortPath.Length - 1);
|
||||
|
||||
|
||||
var entry = frameworks.FirstOrDefault (f => f.Name.Equals (shortPath));
|
||||
if (entry == null) {
|
||||
entry = new FrameworkEntry (frameworks) { Name = shortPath };
|
||||
frameworks.Add (entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>Writes the framework indices to disk.</summary>
|
||||
/// <param name="path">The folder where one file for every FrameworkEntry will be written.</param>
|
||||
public void WriteToDisk (string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace (this.path))
|
||||
return;
|
||||
|
||||
string outputPath = Path.Combine (path, "FrameworksIndex");
|
||||
if (!Directory.Exists (outputPath))
|
||||
Directory.CreateDirectory (outputPath);
|
||||
|
||||
foreach (var fx in this.frameworks) {
|
||||
|
||||
XDocument doc = new XDocument (
|
||||
new XElement("Framework",
|
||||
new XAttribute ("Name", fx.Name),
|
||||
fx.Types
|
||||
.GroupBy(t => t.Namespace)
|
||||
.Select(g => new XElement("Namespace",
|
||||
new XAttribute("Name", g.Key),
|
||||
g.Select (t => new XElement ("Type",
|
||||
new XAttribute ("Name", t.Name),
|
||||
new XAttribute("Id", t.Id),
|
||||
t.Members.Select (m =>
|
||||
new XElement ("Member",
|
||||
new XAttribute ("Id", m)))))))));
|
||||
|
||||
// now save the document
|
||||
string filePath = Path.Combine (outputPath, fx.Name + ".xml");
|
||||
|
||||
if (File.Exists (filePath))
|
||||
File.Delete (filePath);
|
||||
|
||||
var settings = new XmlWriterSettings { Indent = true };
|
||||
using (var writer = XmlWriter.Create (filePath, settings)) {
|
||||
doc.WriteTo (writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
80
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkTypeEntry.cs
vendored
Normal file
80
external/api-doc-tools/mdoc/Mono.Documentation/Frameworks/FrameworkTypeEntry.cs
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Rocks;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
class FrameworkTypeEntry : IComparable<FrameworkTypeEntry>
|
||||
{
|
||||
SortedSet<string> members = new SortedSet<string> ();
|
||||
SortedSet<string> memberscsharpsig = new SortedSet<string> ();
|
||||
|
||||
ILFullMemberFormatter formatter = new ILFullMemberFormatter ();
|
||||
|
||||
FrameworkEntry fx;
|
||||
|
||||
public static FrameworkTypeEntry Empty = new EmptyTypeEntry (FrameworkEntry.Empty) { Name = "Empty" };
|
||||
|
||||
public FrameworkTypeEntry (FrameworkEntry fx)
|
||||
{
|
||||
this.fx = fx;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Namespace { get; set; }
|
||||
public FrameworkEntry Framework { get { return fx; } }
|
||||
|
||||
public ISet<string> Members {
|
||||
get {
|
||||
return this.members;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ProcessMember (MemberReference member)
|
||||
{
|
||||
var resolvedMember = member.Resolve ();
|
||||
if (resolvedMember != null) {
|
||||
var docid = DocCommentId.GetDocCommentId (resolvedMember);
|
||||
members.Add (docid);
|
||||
}
|
||||
else
|
||||
members.Add (member.FullName);
|
||||
|
||||
// this is for lookup purposes
|
||||
try {
|
||||
memberscsharpsig.Add(formatter.GetDeclaration(member));
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
public bool ContainsCSharpSig (string sig)
|
||||
{
|
||||
return memberscsharpsig.Contains (sig);
|
||||
}
|
||||
|
||||
public override string ToString () => $"{this.Name} in {this.fx.Name}";
|
||||
|
||||
public int CompareTo (FrameworkTypeEntry other)
|
||||
{
|
||||
if (other == null) return -1;
|
||||
if (this.Name == null) return 1;
|
||||
|
||||
return string.Compare (this.Name, other.Name, StringComparison.CurrentCulture);
|
||||
}
|
||||
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
FrameworkTypeEntry other = obj as FrameworkTypeEntry;
|
||||
if (other == null) return false;
|
||||
return this.Name.Equals (other.Name);
|
||||
}
|
||||
|
||||
class EmptyTypeEntry : FrameworkTypeEntry
|
||||
{
|
||||
public EmptyTypeEntry (FrameworkEntry fx) : base (fx) { }
|
||||
public override void ProcessMember (MemberReference member) { }
|
||||
}
|
||||
}
|
||||
}
|
83
external/api-doc-tools/mdoc/Mono.Documentation/MdocFile.cs
vendored
Normal file
83
external/api-doc-tools/mdoc/Mono.Documentation/MdocFile.cs
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// MdocFile.cs: File utility methods
|
||||
//
|
||||
// Author:
|
||||
// Jonathan Pryor <jpryor@novell.com>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
static class MdocFile {
|
||||
|
||||
public static void UpdateFile (string file, Action<string> creator)
|
||||
{
|
||||
if (!File.Exists (file) || file == "-") {
|
||||
creator (file);
|
||||
return;
|
||||
}
|
||||
|
||||
string temp = Path.GetTempFileName ();
|
||||
bool move = true;
|
||||
try {
|
||||
creator (temp);
|
||||
|
||||
using (var a = File.OpenRead (file))
|
||||
using (var b = File.OpenRead (temp)) {
|
||||
if (a.Length == b.Length)
|
||||
move = !FileContentsIdentical (a, b);
|
||||
}
|
||||
|
||||
if (move) {
|
||||
File.Delete (file);
|
||||
File.Move (temp, file);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (!move && File.Exists (temp))
|
||||
File.Delete (temp);
|
||||
}
|
||||
}
|
||||
|
||||
static bool FileContentsIdentical (Stream a, Stream b)
|
||||
{
|
||||
byte[] ba = new byte[4096];
|
||||
byte[] bb = new byte[4096];
|
||||
int ra, rb;
|
||||
|
||||
while ((ra = a.Read (ba, 0, ba.Length)) > 0 &&
|
||||
(rb = b.Read (bb, 0, bb.Length)) > 0) {
|
||||
if (ra != rb)
|
||||
return false;
|
||||
for (int i = 0; i < ra; ++i) {
|
||||
if (ba [i] != bb [i])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
252
external/api-doc-tools/mdoc/Mono.Documentation/XhtmlWriter.cs
vendored
Normal file
252
external/api-doc-tools/mdoc/Mono.Documentation/XhtmlWriter.cs
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
//
|
||||
// XhtmlWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <atsushi@ximian.com>
|
||||
// Jonathan Pryor <jpryor@novell.com>
|
||||
//
|
||||
// (C)2004 Atsushi Enomoto
|
||||
//
|
||||
//
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class XhtmlWriter : DelegatingXmlWriter {
|
||||
XmlWriter writer;
|
||||
Stack<string> localNames;
|
||||
Stack<string> namespaces;
|
||||
|
||||
public XhtmlWriter (XmlWriter writer) : base (writer)
|
||||
{
|
||||
this.writer = writer;
|
||||
localNames = new Stack<string> ();
|
||||
namespaces = new Stack<string> ();
|
||||
}
|
||||
|
||||
public override void WriteStartElement (string prefix, string localName, string ns)
|
||||
{
|
||||
localNames.Push (localName);
|
||||
namespaces.Push (ns);
|
||||
writer.WriteStartElement (prefix, localName, ns);
|
||||
}
|
||||
|
||||
public override void WriteEndElement ()
|
||||
{
|
||||
WriteWiseEndElement (false);
|
||||
}
|
||||
|
||||
public override void WriteFullEndElement ()
|
||||
{
|
||||
WriteWiseEndElement (true);
|
||||
}
|
||||
|
||||
void WriteWiseEndElement (bool full)
|
||||
{
|
||||
string localName = localNames.Pop ();
|
||||
/* string ns = */ namespaces.Pop ();
|
||||
if (true /* ns == "http://www.w3.org/1999/xhtml" */) {
|
||||
switch (localName.ToLower (CultureInfo.InvariantCulture)) {
|
||||
case "area":
|
||||
case "base":
|
||||
case "basefont":
|
||||
case "br":
|
||||
case "col":
|
||||
case "frame":
|
||||
case "hr":
|
||||
case "img":
|
||||
case "input":
|
||||
case "isindex":
|
||||
case "link":
|
||||
case "meta":
|
||||
case "param":
|
||||
full = false;
|
||||
break;
|
||||
default:
|
||||
full = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (full)
|
||||
writer.WriteFullEndElement ();
|
||||
else
|
||||
writer.WriteEndElement ();
|
||||
}
|
||||
}
|
||||
|
||||
class DelegatingXmlWriter : XmlWriter {
|
||||
XmlWriter writer;
|
||||
|
||||
public DelegatingXmlWriter (XmlWriter writer)
|
||||
{
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
public override void Close ()
|
||||
{
|
||||
writer.Close ();
|
||||
}
|
||||
|
||||
public override void Flush ()
|
||||
{
|
||||
writer.Flush ();
|
||||
}
|
||||
|
||||
public override string LookupPrefix (string ns)
|
||||
{
|
||||
return writer.LookupPrefix (ns);
|
||||
}
|
||||
|
||||
public override void WriteBase64 (byte [] buffer, int index, int count)
|
||||
{
|
||||
writer.WriteBase64 (buffer, index, count);
|
||||
}
|
||||
|
||||
public override void WriteBinHex (byte [] buffer, int index, int count)
|
||||
{
|
||||
writer.WriteBinHex (buffer, index, count);
|
||||
}
|
||||
|
||||
public override void WriteCData (string text)
|
||||
{
|
||||
writer.WriteCData (text);
|
||||
}
|
||||
|
||||
public override void WriteCharEntity (char ch)
|
||||
{
|
||||
writer.WriteCharEntity (ch);
|
||||
}
|
||||
|
||||
public override void WriteChars (char [] buffer, int index, int count)
|
||||
{
|
||||
writer.WriteChars (buffer, index, count);
|
||||
}
|
||||
|
||||
public override void WriteComment (string text)
|
||||
{
|
||||
writer.WriteComment (text);
|
||||
}
|
||||
|
||||
public override void WriteDocType (string name, string pubid, string sysid, string subset)
|
||||
{
|
||||
writer.WriteDocType (name, pubid, sysid, subset);
|
||||
}
|
||||
|
||||
public override void WriteEndAttribute ()
|
||||
{
|
||||
writer.WriteEndAttribute ();
|
||||
}
|
||||
|
||||
public override void WriteEndDocument ()
|
||||
{
|
||||
writer.WriteEndDocument ();
|
||||
}
|
||||
|
||||
public override void WriteEndElement ()
|
||||
{
|
||||
writer.WriteEndElement ();
|
||||
}
|
||||
|
||||
public override void WriteEntityRef (string name)
|
||||
{
|
||||
writer.WriteEntityRef (name);
|
||||
}
|
||||
|
||||
public override void WriteFullEndElement ()
|
||||
{
|
||||
writer.WriteFullEndElement ();
|
||||
}
|
||||
|
||||
public override void WriteName (string name)
|
||||
{
|
||||
writer.WriteName (name);
|
||||
}
|
||||
|
||||
public override void WriteNmToken (string name)
|
||||
{
|
||||
writer.WriteNmToken (name);
|
||||
}
|
||||
|
||||
public override void WriteNode (XmlReader reader, bool defattr)
|
||||
{
|
||||
writer.WriteNode (reader, defattr);
|
||||
}
|
||||
|
||||
public override void WriteProcessingInstruction (string name, string text)
|
||||
{
|
||||
writer.WriteProcessingInstruction (name, text);
|
||||
}
|
||||
|
||||
public override void WriteQualifiedName (string localName, string ns)
|
||||
{
|
||||
writer.WriteQualifiedName (localName, ns);
|
||||
}
|
||||
|
||||
public override void WriteRaw (string data)
|
||||
{
|
||||
writer.WriteRaw (data);
|
||||
}
|
||||
|
||||
public override void WriteRaw (char [] buffer, int index, int count)
|
||||
{
|
||||
writer.WriteRaw (buffer, index, count);
|
||||
}
|
||||
|
||||
public override void WriteStartAttribute (string prefix, string localName, string ns)
|
||||
{
|
||||
writer.WriteStartAttribute (prefix, localName, ns);
|
||||
}
|
||||
|
||||
public override void WriteStartDocument (bool standalone)
|
||||
{
|
||||
writer.WriteStartDocument (standalone);
|
||||
}
|
||||
|
||||
public override void WriteStartDocument ()
|
||||
{
|
||||
writer.WriteStartDocument ();
|
||||
}
|
||||
|
||||
public override void WriteStartElement (string prefix, string localName, string ns)
|
||||
{
|
||||
writer.WriteStartElement (prefix, localName, ns);
|
||||
}
|
||||
|
||||
public override void WriteString (string text)
|
||||
{
|
||||
writer.WriteString (text);
|
||||
}
|
||||
|
||||
public override void WriteSurrogateCharEntity (char lowChar, char highChar)
|
||||
{
|
||||
writer.WriteSurrogateCharEntity (lowChar, highChar);
|
||||
}
|
||||
|
||||
public override void WriteWhitespace (string ws)
|
||||
{
|
||||
writer.WriteWhitespace (ws);
|
||||
}
|
||||
|
||||
public override WriteState WriteState {
|
||||
get {
|
||||
return writer.WriteState;
|
||||
}
|
||||
}
|
||||
|
||||
public override string XmlLang {
|
||||
get {
|
||||
return writer.XmlLang;
|
||||
}
|
||||
}
|
||||
|
||||
public override XmlSpace XmlSpace {
|
||||
get {
|
||||
return writer.XmlSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
415
external/api-doc-tools/mdoc/Mono.Documentation/assembler.cs
vendored
Normal file
415
external/api-doc-tools/mdoc/Mono.Documentation/assembler.cs
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
//
|
||||
// The assembler: Help compiler.
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza (miguel@gnome.org)
|
||||
//
|
||||
// (C) 2003 Ximian, Inc.
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Monodoc;
|
||||
using Monodoc.Providers;
|
||||
using Mono.Options;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Monodoc.Ecma;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
public class MDocAssembler : MDocCommand {
|
||||
static readonly string[] ValidFormats = {
|
||||
"ecma",
|
||||
"ecmaspec",
|
||||
"error",
|
||||
"hb",
|
||||
"man",
|
||||
"simple",
|
||||
"xhtml"
|
||||
};
|
||||
|
||||
string droppedNamespace = null;
|
||||
|
||||
public static Option[] CreateFormatOptions (MDocCommand self, Dictionary<string, List<string>> formats)
|
||||
{
|
||||
string cur_format = "ecma";
|
||||
var options = new OptionSet () {
|
||||
{ "f|format=",
|
||||
"The documentation {FORMAT} used in DIRECTORIES. " +
|
||||
"Valid formats include:\n " +
|
||||
string.Join ("\n ", ValidFormats) + "\n" +
|
||||
"If not specified, the default format is `ecma'.",
|
||||
v => {
|
||||
if (Array.IndexOf (ValidFormats, v) < 0)
|
||||
self.Error ("Invalid documentation format: {0}.", v);
|
||||
cur_format = v;
|
||||
} },
|
||||
{ "<>", v => AddFormat (self, formats, cur_format, v) },
|
||||
};
|
||||
return new Option[]{options[0], options[1]};
|
||||
}
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
bool replaceNTypes = false;
|
||||
var formats = new Dictionary<string, List<string>> ();
|
||||
string prefix = "tree";
|
||||
var formatOptions = CreateFormatOptions (this, formats);
|
||||
var options = new OptionSet () {
|
||||
formatOptions [0],
|
||||
{ "o|out=",
|
||||
"Provides the output file prefix; the files {PREFIX}.zip and " +
|
||||
"{PREFIX}.tree will be created.\n" +
|
||||
"If not specified, `tree' is the default PREFIX.",
|
||||
v => prefix = v },
|
||||
formatOptions [1],
|
||||
{"dropns=","The namespace that has been dropped from this version of the assembly.", v => droppedNamespace = v },
|
||||
{"ntypes","Replace references to native types with their original types.", v => replaceNTypes=true },
|
||||
};
|
||||
List<string> extra = Parse (options, args, "assemble",
|
||||
"[OPTIONS]+ DIRECTORIES",
|
||||
"Assemble documentation within DIRECTORIES for use within the monodoc browser.");
|
||||
if (extra == null)
|
||||
return;
|
||||
|
||||
List<Provider> list = new List<Provider> ();
|
||||
EcmaProvider ecma = null;
|
||||
bool sort = false;
|
||||
|
||||
foreach (string format in formats.Keys) {
|
||||
switch (format) {
|
||||
case "ecma":
|
||||
if (ecma == null) {
|
||||
ecma = new EcmaProvider ();
|
||||
list.Add (ecma);
|
||||
sort = true;
|
||||
}
|
||||
ecma.FileSource = new MDocFileSource(droppedNamespace, string.IsNullOrWhiteSpace(droppedNamespace) ? ApiStyle.Unified : ApiStyle.Classic) {
|
||||
ReplaceNativeTypes = replaceNTypes
|
||||
};
|
||||
foreach (string dir in formats [format])
|
||||
ecma.AddDirectory (dir);
|
||||
break;
|
||||
|
||||
case "xhtml":
|
||||
case "hb":
|
||||
list.AddRange (formats [format].Select (d => (Provider) new XhtmlProvider (d)));
|
||||
break;
|
||||
|
||||
case "man":
|
||||
list.Add (new ManProvider (formats [format].ToArray ()));
|
||||
break;
|
||||
|
||||
case "error":
|
||||
list.AddRange (formats [format].Select (d => (Provider) new ErrorProvider (d)));
|
||||
break;
|
||||
|
||||
case "ecmaspec":
|
||||
list.AddRange (formats [format].Select (d => (Provider) new EcmaSpecProvider (d)));
|
||||
break;
|
||||
|
||||
case "addins":
|
||||
list.AddRange (formats [format].Select (d => (Provider) new AddinsProvider (d)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HelpSource hs = new HelpSource (prefix, true);
|
||||
hs.TraceLevel = TraceLevel;
|
||||
|
||||
foreach (Provider p in list) {
|
||||
p.PopulateTree (hs.Tree);
|
||||
}
|
||||
|
||||
if (sort && hs.Tree != null)
|
||||
hs.Tree.RootNode.Sort ();
|
||||
|
||||
//
|
||||
// Flushes the EcmaProvider
|
||||
//
|
||||
foreach (Provider p in list)
|
||||
p.CloseTree (hs, hs.Tree);
|
||||
|
||||
hs.Save ();
|
||||
}
|
||||
|
||||
private static void AddFormat (MDocCommand self, Dictionary<string, List<string>> d, string format, string file)
|
||||
{
|
||||
if (format == null)
|
||||
self.Error ("No format specified.");
|
||||
List<string> l;
|
||||
if (!d.TryGetValue (format, out l)) {
|
||||
l = new List<string> ();
|
||||
d.Add (format, l);
|
||||
}
|
||||
l.Add (file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom provider file source that lets us modify the source files before they are processed by monodoc.
|
||||
/// </summary>
|
||||
internal class MDocFileSource : IEcmaProviderFileSource {
|
||||
private string droppedNamespace;
|
||||
private bool shouldDropNamespace = false;
|
||||
private ApiStyle styleToDrop;
|
||||
|
||||
public bool ReplaceNativeTypes { get; set; }
|
||||
|
||||
/// <param name="ns">The namespace that is being dropped.</param>
|
||||
/// <param name="style">The style that is being dropped.</param>
|
||||
public MDocFileSource(string ns, ApiStyle style)
|
||||
{
|
||||
droppedNamespace = ns;
|
||||
shouldDropNamespace = !string.IsNullOrWhiteSpace (ns);
|
||||
styleToDrop = style;
|
||||
}
|
||||
|
||||
public XmlReader GetIndexReader(string path)
|
||||
{
|
||||
XDocument doc = XDocument.Load (path);
|
||||
|
||||
DropApiStyle (doc, path);
|
||||
DropNSFromDocument (doc);
|
||||
|
||||
// now put the modified contents into a stream for the XmlReader that monodoc will use.
|
||||
MemoryStream io = new MemoryStream ();
|
||||
using (var writer = XmlWriter.Create (io)) {
|
||||
doc.WriteTo (writer);
|
||||
}
|
||||
io.Seek (0, SeekOrigin.Begin);
|
||||
|
||||
return XmlReader.Create (io);
|
||||
}
|
||||
|
||||
public XElement GetNamespaceElement(string path)
|
||||
{
|
||||
var element = XElement.Load (path);
|
||||
|
||||
var attributes = element.Descendants ().Concat(new XElement[] { element }).SelectMany (n => n.Attributes ());
|
||||
var textNodes = element.Nodes ().OfType<XText> ();
|
||||
|
||||
DropNS (attributes, textNodes);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void DropApiStyle(XDocument doc, string path)
|
||||
{
|
||||
string styleString = styleToDrop.ToString ().ToLower ();
|
||||
var items = doc
|
||||
.Descendants ()
|
||||
.Where (n => n.Attributes ()
|
||||
.Any (a => a.Name.LocalName == "apistyle" && a.Value == styleString))
|
||||
.ToArray ();
|
||||
|
||||
foreach (var element in items) {
|
||||
element.Remove ();
|
||||
}
|
||||
|
||||
if (styleToDrop == ApiStyle.Classic && ReplaceNativeTypes) {
|
||||
RewriteCrefsIfNecessary (doc, path);
|
||||
}
|
||||
}
|
||||
|
||||
void RewriteCrefsIfNecessary (XDocument doc, string path)
|
||||
{
|
||||
// we also have to rewrite crefs
|
||||
var sees = doc.Descendants ().Where (d => d.Name.LocalName == "see").ToArray ();
|
||||
foreach (var see in sees) {
|
||||
var cref = see.Attribute ("cref");
|
||||
if (cref == null) {
|
||||
continue;
|
||||
}
|
||||
EcmaUrlParser parser = new EcmaUrlParser ();
|
||||
EcmaDesc reference;
|
||||
if (!parser.TryParse (cref.Value, out reference)) {
|
||||
continue;
|
||||
}
|
||||
if ((new EcmaDesc.Kind[] {
|
||||
EcmaDesc.Kind.Constructor,
|
||||
EcmaDesc.Kind.Method
|
||||
}).Any (k => k == reference.DescKind)) {
|
||||
string ns = reference.Namespace;
|
||||
string type = reference.TypeName;
|
||||
string memberName = reference.MemberName;
|
||||
if (reference.MemberArguments != null) {
|
||||
XDocument refDoc = FindReferenceDoc (path, doc, ns, type);
|
||||
if (refDoc == null) {
|
||||
continue;
|
||||
}
|
||||
// look in the refDoc for the memberName, and match on parameters and # of type parameters
|
||||
var overloads = refDoc.XPathSelectElements ("//Member[@MemberName='" + memberName + "']").ToArray ();
|
||||
// Do some initial filtering to find members that could potentially match (based on parameter and typeparam counts)
|
||||
var members = overloads.Where (e => reference.MemberArgumentsCount == e.XPathSelectElements ("Parameters/Parameter[not(@apistyle) or @apistyle='classic']").Count () && reference.GenericMemberArgumentsCount == e.XPathSelectElements ("TypeParameters/TypeParameter[not(@apistyle) or @apistyle='classic']").Count ()).Select (m => new {
|
||||
Node = m,
|
||||
AllParameters = m.XPathSelectElements ("Parameters/Parameter").ToArray (),
|
||||
Parameters = m.XPathSelectElements ("Parameters/Parameter[not(@apistyle) or @apistyle='classic']").ToArray (),
|
||||
NewParameters = m.XPathSelectElements ("Parameters/Parameter[@apistyle='unified']").ToArray ()
|
||||
}).ToArray ();
|
||||
// now find the member that matches on types
|
||||
var member = members.FirstOrDefault (m => reference.MemberArguments.All (r => m.Parameters.Any (mp => mp.Attribute ("Type").Value.Contains (r.TypeName))));
|
||||
if (member == null || member.NewParameters.Length == 0)
|
||||
continue;
|
||||
foreach (var arg in reference.MemberArguments) {
|
||||
// find the "classic" parameter
|
||||
var oldParam = member.Parameters.First (p => p.Attribute ("Type").Value.Contains (arg.TypeName));
|
||||
var newParam = member.NewParameters.FirstOrDefault (p => oldParam.Attribute ("Name").Value == p.Attribute ("Name").Value);
|
||||
if (newParam != null) {
|
||||
// this means there was a change made, and we should try to convert this cref
|
||||
arg.TypeName = NativeTypeManager.ConvertToNativeType (arg.TypeName);
|
||||
}
|
||||
}
|
||||
var rewrittenReference = reference.ToEcmaCref ();
|
||||
Console.WriteLine ("From {0} to {1}", cref.Value, rewrittenReference);
|
||||
cref.Value = rewrittenReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XDocument FindReferenceDoc (string currentPath, XDocument currentDoc, string ns, string type)
|
||||
{
|
||||
if (currentPath.Length <= 1) {
|
||||
return null;
|
||||
}
|
||||
// build up the supposed path to the doc
|
||||
string dir = Path.GetDirectoryName (currentPath);
|
||||
if (dir.Equals (currentPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
string supposedPath = Path.Combine (dir, ns, type + ".xml");
|
||||
|
||||
// if it's the current path, return currentDoc
|
||||
if (supposedPath == currentPath) {
|
||||
return currentDoc;
|
||||
}
|
||||
|
||||
if (!File.Exists (supposedPath)) {
|
||||
// hmm, file not there, look one directory up
|
||||
return FindReferenceDoc (dir, currentDoc, ns, type);
|
||||
}
|
||||
|
||||
// otherwise, load the XDoc and return
|
||||
return XDocument.Load (supposedPath);
|
||||
}
|
||||
|
||||
void DropNSFromDocument (XDocument doc)
|
||||
{
|
||||
var attributes = doc.Descendants ().SelectMany (n => n.Attributes ());
|
||||
var textNodes = doc.DescendantNodes().OfType<XText> ().ToArray();
|
||||
|
||||
DropNS (attributes, textNodes);
|
||||
}
|
||||
|
||||
void DropNS(IEnumerable<XAttribute> attributes, IEnumerable<XText> textNodes)
|
||||
{
|
||||
if (!shouldDropNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
string nsString = string.Format ("{0}.", droppedNamespace);
|
||||
foreach (var attr in attributes) {
|
||||
if (attr.Value.Contains (nsString)) {
|
||||
attr.Value = attr.Value.Replace (nsString, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var textNode in textNodes) {
|
||||
if (textNode.Value.Contains (nsString)) {
|
||||
textNode.Value = textNode.Value.Replace (nsString, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <param name="nsName">This is the type's name in the processed XML content.
|
||||
/// If dropping the namespace, we'll need to append it so that it's found in the source.</param>
|
||||
/// <param name="typeName">Type name.</param>
|
||||
public string GetTypeXmlPath(string basePath, string nsName, string typeName)
|
||||
{
|
||||
string nsNameToUse = nsName;
|
||||
if (shouldDropNamespace) {
|
||||
nsNameToUse = string.Format ("{0}.{1}", droppedNamespace, nsName);
|
||||
|
||||
var droppedPath = BuildTypeXmlPath (basePath, typeName, nsNameToUse);
|
||||
var origPath = BuildTypeXmlPath (basePath, typeName, nsName);
|
||||
|
||||
if (!File.Exists (droppedPath)) {
|
||||
if (File.Exists (origPath)) {
|
||||
return origPath;
|
||||
}
|
||||
}
|
||||
|
||||
return droppedPath;
|
||||
} else {
|
||||
|
||||
var finalPath = BuildTypeXmlPath (basePath, typeName, nsNameToUse);
|
||||
|
||||
return finalPath;
|
||||
}
|
||||
}
|
||||
|
||||
static string BuildTypeXmlPath (string basePath, string typeName, string nsNameToUse)
|
||||
{
|
||||
string finalPath = Path.Combine (basePath, nsNameToUse, Path.ChangeExtension (typeName, ".xml"));
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
static string BuildNamespaceXmlPath (string basePath, string ns)
|
||||
{
|
||||
var nsFileName = Path.Combine (basePath, String.Format ("ns-{0}.xml", ns));
|
||||
return nsFileName;
|
||||
}
|
||||
|
||||
/// <returns>The namespace for path, with the dropped namespace so it can be used to pick the right file if we're dropping it.</returns>
|
||||
/// <param name="ns">This namespace will already have "dropped" the namespace.</param>
|
||||
public string GetNamespaceXmlPath(string basePath, string ns)
|
||||
{
|
||||
string nsNameToUse = ns;
|
||||
if (shouldDropNamespace) {
|
||||
nsNameToUse = string.Format ("{0}.{1}", droppedNamespace, ns);
|
||||
|
||||
var droppedPath = BuildNamespaceXmlPath (basePath, nsNameToUse);
|
||||
var origPath = BuildNamespaceXmlPath (basePath, ns);
|
||||
|
||||
if (!File.Exists (droppedPath) && File.Exists(origPath)) {
|
||||
return origPath;
|
||||
}
|
||||
|
||||
return droppedPath;
|
||||
} else {
|
||||
var path = BuildNamespaceXmlPath (basePath, ns);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public XDocument GetTypeDocument(string path)
|
||||
{
|
||||
var doc = XDocument.Load (path);
|
||||
DropApiStyle (doc, path);
|
||||
DropNSFromDocument (doc);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
public XElement ExtractNamespaceSummary (string path)
|
||||
{
|
||||
using (var reader = GetIndexReader (path)) {
|
||||
reader.ReadToFollowing ("Namespace");
|
||||
var name = reader.GetAttribute ("Name");
|
||||
var summary = reader.ReadToFollowing ("summary") ? XElement.Load (reader.ReadSubtree ()) : new XElement ("summary");
|
||||
var remarks = reader.ReadToFollowing ("remarks") ? XElement.Load (reader.ReadSubtree ()) : new XElement ("remarks");
|
||||
|
||||
return new XElement ("namespace",
|
||||
new XAttribute ("ns", name ?? string.Empty),
|
||||
summary,
|
||||
remarks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
external/api-doc-tools/mdoc/Mono.Documentation/dump.cs
vendored
Normal file
60
external/api-doc-tools/mdoc/Mono.Documentation/dump.cs
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
using Mono.Options;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class MDocTreeDumper : MDocCommand {
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
var validFormats = RootTree.GetSupportedFormats ();
|
||||
string cur_format = "";
|
||||
var formats = new Dictionary<string, List<string>> ();
|
||||
var options = new OptionSet () {
|
||||
{ "f|format=",
|
||||
"The documentation {FORMAT} used in FILES. " +
|
||||
"Valid formats include:\n " +
|
||||
string.Join ("\n ", validFormats) + "\n" +
|
||||
"If not specified, no HelpSource is used. This may " +
|
||||
"impact the PublicUrls displayed for nodes.",
|
||||
v => {
|
||||
if (Array.IndexOf (validFormats, v) < 0)
|
||||
Error ("Invalid documentation format: {0}.", v);
|
||||
cur_format = v;
|
||||
} },
|
||||
{ "<>", v => AddFormat (formats, cur_format, v) },
|
||||
};
|
||||
List<string> files = Parse (options, args, "dump-tree",
|
||||
"[OPTIONS]+ FILES",
|
||||
"Print out the nodes within the assembled .tree FILES,\n" +
|
||||
"as produced by 'mdoc assemble'.");
|
||||
if (files == null)
|
||||
return;
|
||||
|
||||
foreach (string format in formats.Keys) {
|
||||
foreach (string file in formats [format]) {
|
||||
HelpSource hs = format == ""
|
||||
? null
|
||||
: RootTree.GetHelpSource (format, file.Replace (".tree", ""));
|
||||
Tree t = new Tree (hs, file);
|
||||
TreeDumper.PrintTree (t.RootNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddFormat (Dictionary<string, List<string>> d, string format, string file)
|
||||
{
|
||||
if (format == null)
|
||||
format = "";
|
||||
List<string> l;
|
||||
if (!d.TryGetValue (format, out l)) {
|
||||
l = new List<string> ();
|
||||
d.Add (format, l);
|
||||
}
|
||||
l.Add (file);
|
||||
}
|
||||
}
|
||||
}
|
331
external/api-doc-tools/mdoc/Mono.Documentation/ecmadoc.cs
vendored
Normal file
331
external/api-doc-tools/mdoc/Mono.Documentation/ecmadoc.cs
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
//
|
||||
// ecmadoc.cs
|
||||
//
|
||||
// Author:
|
||||
// Jonathan Pryor <jpryor@novell.com>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
using Monodoc;
|
||||
using Mono.Documentation;
|
||||
|
||||
using Mono.Options;
|
||||
using Mono.Rocks;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
public class MDocUpdateEcmaXml : MDocCommand
|
||||
{
|
||||
string file = "CLILibraryTypes.xml";
|
||||
List<string> directories;
|
||||
Dictionary<string, HashSet<string>> libraries = new Dictionary<string, HashSet<string>>();
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
string current_library = "";
|
||||
|
||||
var options = new OptionSet () {
|
||||
{ "o|out=",
|
||||
"{FILE} to generate/update documentation within.\n" +
|
||||
"If not specified, will process " + file + ".\n" +
|
||||
"Set to '-' to skip updates and write to standard output.",
|
||||
v => file = v },
|
||||
{ "library=",
|
||||
"The {LIBRARY} that the following --type=TYPE types should be a part of.",
|
||||
v => current_library = v },
|
||||
{ "type=",
|
||||
"The full {TYPE} name of a type to copy into the output file.",
|
||||
v => AddTypeToLibrary (current_library, v) },
|
||||
};
|
||||
directories = Parse (options, args, "export-ecma-xml",
|
||||
"[OPTIONS]+ DIRECTORIES",
|
||||
"Export mdoc documentation within DIRECTORIES into ECMA-format XML.\n\n" +
|
||||
"DIRECTORIES are mdoc(5) directories as produced by 'mdoc update'.");
|
||||
if (directories == null || directories.Count == 0)
|
||||
return;
|
||||
|
||||
Update ();
|
||||
}
|
||||
|
||||
void AddTypeToLibrary (string library, string type)
|
||||
{
|
||||
HashSet<string> types;
|
||||
if (!libraries.TryGetValue (library, out types))
|
||||
libraries.Add (library, types = new HashSet<string> ());
|
||||
types.Add (type.Replace ('/', '.').Replace ('+', '.'));
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
Action<string> creator = file => {
|
||||
XDocument docs = LoadFile (this.file);
|
||||
|
||||
var seenLibraries = new HashSet<string> ();
|
||||
|
||||
UpdateExistingLibraries (docs, seenLibraries);
|
||||
GenerateMissingLibraries (docs, seenLibraries);
|
||||
|
||||
SortLibraries (docs.Root);
|
||||
SortTypes (docs.Root);
|
||||
|
||||
using (var output = CreateWriter (file)) {
|
||||
foreach (var node in docs.Nodes ()) {
|
||||
if (node.NodeType == XmlNodeType.Element || node.NodeType == XmlNodeType.Text)
|
||||
continue;
|
||||
node.WriteTo (output);
|
||||
}
|
||||
docs.Root.WriteTo (output);
|
||||
output.WriteWhitespace ("\r\n");
|
||||
}
|
||||
};
|
||||
MdocFile.UpdateFile (this.file, creator);
|
||||
}
|
||||
|
||||
static XDocument LoadFile (string file)
|
||||
{
|
||||
if (file == "-" || !File.Exists (file))
|
||||
return CreateDefaultDocument ();
|
||||
|
||||
var settings = new XmlReaderSettings {
|
||||
DtdProcessing = DtdProcessing.Parse
|
||||
};
|
||||
using (var reader = XmlReader.Create (file, settings))
|
||||
return XDocument.Load (reader);
|
||||
}
|
||||
|
||||
static XDocument CreateDefaultDocument ()
|
||||
{
|
||||
return new XDocument (
|
||||
new XComment (" ====================================================================== "),
|
||||
new XComment (" This XML is a description of the Common Language Infrastructure (CLI) library. "),
|
||||
new XComment (" This file is a normative part of Partition IV of the following standards: ISO/IEC 23271 and ECMA 335 "),
|
||||
new XComment (" ====================================================================== "),
|
||||
new XDocumentType ("Libraries", null, "CLILibraryTypes.dtd", null),
|
||||
new XElement ("Libraries"));
|
||||
}
|
||||
|
||||
static XmlWriter CreateWriter (string file)
|
||||
{
|
||||
var settings = new XmlWriterSettings {
|
||||
Indent = true,
|
||||
IndentChars = "\t",
|
||||
NewLineChars = "\r\n",
|
||||
OmitXmlDeclaration = true,
|
||||
};
|
||||
|
||||
if (file == "-")
|
||||
return XmlWriter.Create (Console.Out, settings);
|
||||
|
||||
settings.Encoding = new UTF8Encoding (false);
|
||||
return XmlWriter.Create (file, settings);
|
||||
}
|
||||
|
||||
void UpdateExistingLibraries (XDocument docs, HashSet<string> seenLibraries)
|
||||
{
|
||||
foreach (XElement types in docs.Root.Elements ("Types")) {
|
||||
XAttribute library = types.Attribute ("Library");
|
||||
HashSet<string> libraryTypes;
|
||||
if (library == null || !libraries.TryGetValue (library.Value, out libraryTypes)) {
|
||||
continue;
|
||||
}
|
||||
seenLibraries.Add (library.Value);
|
||||
var seenTypes = new HashSet<string> ();
|
||||
foreach (XElement type in types.Elements ("Type").ToList ()) {
|
||||
XAttribute fullName = type.Attribute ("FullName");
|
||||
string typeName = fullName == null
|
||||
? null
|
||||
: XmlDocUtils.ToEscapedTypeName (fullName.Value);
|
||||
if (typeName == null || !libraryTypes.Contains (typeName)) {
|
||||
continue;
|
||||
}
|
||||
type.Remove ();
|
||||
seenTypes.Add (typeName);
|
||||
types.Add (LoadType (typeName, library.Value));
|
||||
}
|
||||
foreach (string typeName in libraryTypes.Except (seenTypes))
|
||||
types.Add (LoadType (typeName, library.Value));
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateMissingLibraries (XDocument docs, HashSet<string> seenLibraries)
|
||||
{
|
||||
foreach (KeyValuePair<string, HashSet<string>> lib in libraries) {
|
||||
if (seenLibraries.Contains (lib.Key))
|
||||
continue;
|
||||
seenLibraries.Add (lib.Key);
|
||||
docs.Root.Add (new XElement ("Types", new XAttribute ("Library", lib.Key),
|
||||
lib.Value.Select (type => LoadType (type, lib.Key))));
|
||||
}
|
||||
}
|
||||
|
||||
XElement LoadType (string type, string library)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> permutation in GetTypeDirectoryFilePermutations (type)) {
|
||||
foreach (string root in directories) {
|
||||
string path = Path.Combine (root, Path.Combine (permutation.Key, permutation.Value + ".xml"));
|
||||
if (File.Exists (path))
|
||||
return FixupType (path, library);
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException ("Unable to find documentation file for type: " + type + ".");
|
||||
}
|
||||
|
||||
// type has been "normalized", which (alas) means we have ~no clue which
|
||||
// part is the namespace and which is the type name, particularly
|
||||
// problematic as types may be nested to any level.
|
||||
// Try ~all permutations. :-)
|
||||
static IEnumerable<KeyValuePair<string, string>> GetTypeDirectoryFilePermutations (string type)
|
||||
{
|
||||
int end = type.Length;
|
||||
int dot;
|
||||
while ((dot = type.LastIndexOf ('.', end-1)) >= 0) {
|
||||
yield return new KeyValuePair<string, string> (
|
||||
type.Substring (0, dot),
|
||||
type.Substring (dot+1).Replace ('.', '+'));
|
||||
end = dot;
|
||||
}
|
||||
yield return new KeyValuePair<string, string> ("", type.Replace ('.', '+'));
|
||||
}
|
||||
|
||||
static XElement FixupType (string path, string library)
|
||||
{
|
||||
var type = XElement.Load (path);
|
||||
|
||||
XAttribute fullName = type.Attribute ("FullName");
|
||||
XAttribute fullNameSp = type.Attribute ("FullNameSP");
|
||||
if (fullNameSp == null && fullName != null) {
|
||||
type.Add (new XAttribute ("FullNameSP", fullName.Value.Replace ('.', '_')));
|
||||
}
|
||||
if (type.Element ("TypeExcluded") == null)
|
||||
type.Add (new XElement ("TypeExcluded", "0"));
|
||||
if (type.Element ("MemberOfLibrary") == null) {
|
||||
XElement member = new XElement ("MemberOfLibrary", library);
|
||||
XElement assemblyInfo = type.Element ("AssemblyInfo");
|
||||
if (assemblyInfo != null)
|
||||
assemblyInfo.AddBeforeSelf (member);
|
||||
else
|
||||
type.Add (member);
|
||||
}
|
||||
|
||||
XElement ai = type.Element ("AssemblyInfo");
|
||||
|
||||
XElement assembly =
|
||||
XElement.Load (
|
||||
Path.Combine (
|
||||
Path.Combine (Path.GetDirectoryName (path), ".."),
|
||||
"index.xml"))
|
||||
.Element ("Assemblies")
|
||||
.Elements ("Assembly")
|
||||
.FirstOrDefault (a => a.Attribute ("Name").Value == ai.Element ("AssemblyName").Value &&
|
||||
a.Attribute ("Version").Value == ai.Element ("AssemblyVersion").Value);
|
||||
if (assembly == null)
|
||||
return type;
|
||||
|
||||
if (assembly.Element ("AssemblyPublicKey") != null)
|
||||
ai.Add (assembly.Element ("AssemblyPublicKey"));
|
||||
|
||||
if (assembly.Element ("AssemblyCulture") != null)
|
||||
ai.Add (assembly.Element ("AssemblyCulture"));
|
||||
else
|
||||
ai.Add (new XElement ("AssemblyCulture", "neutral"));
|
||||
|
||||
// TODO: assembly attributes?
|
||||
// The problem is that .NET mscorlib.dll v4.0 has ~26 attributes, and
|
||||
// importing these for every time seems like some serious bloat...
|
||||
var clsDefAttr = assembly.Elements ("Attributes").Elements ("Attribute")
|
||||
.FirstOrDefault (a => a.Element ("AttributeName").Value.StartsWith ("System.CLSCompliant"));
|
||||
if (clsDefAttr != null &&
|
||||
ai.Elements ("Attributes").Elements ("Attribute")
|
||||
.FirstOrDefault (a => a.Element ("AttributeName").Value.StartsWith ("System.CLSCompliant")) == null) {
|
||||
var dest = ai.Element ("Attributes");
|
||||
if (dest == null)
|
||||
ai.Add (dest = new XElement ("Attributes"));
|
||||
dest.Add (clsDefAttr);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void SortLibraries (XContainer libraries)
|
||||
{
|
||||
SortElements (libraries, (x, y) => x.Attribute ("Library").Value.CompareTo (y.Attribute ("Library").Value));
|
||||
}
|
||||
|
||||
static void SortElements (XContainer container, Comparison<XElement> comparison)
|
||||
{
|
||||
var items = new List<XElement> ();
|
||||
foreach (var e in container.Elements ())
|
||||
items.Add (e);
|
||||
items.Sort (comparison);
|
||||
for (int i = items.Count - 1; i > 0; --i) {
|
||||
items [i-1].Remove ();
|
||||
items [i].AddBeforeSelf (items [i-1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void SortTypes (XContainer libraries)
|
||||
{
|
||||
foreach (var types in libraries.Elements ("Types")) {
|
||||
SortElements (types, (x, y) => {
|
||||
string xName, yName;
|
||||
int xCount, yCount;
|
||||
|
||||
GetTypeSortName (x, out xName, out xCount);
|
||||
GetTypeSortName (y, out yName, out yCount);
|
||||
|
||||
int c = xName.CompareTo (yName);
|
||||
if (c != 0)
|
||||
return c;
|
||||
if (xCount < yCount)
|
||||
return -1;
|
||||
if (yCount < xCount)
|
||||
return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void GetTypeSortName (XElement element, out string name, out int typeParamCount)
|
||||
{
|
||||
typeParamCount = 0;
|
||||
name = element.Attribute ("Name").Value;
|
||||
|
||||
int lt = name.IndexOf ('<');
|
||||
if (lt >= 0) {
|
||||
int gt = name.IndexOf ('>', lt);
|
||||
if (gt >= 0) {
|
||||
typeParamCount = name.Substring (lt, gt-lt).Count (c => c == ',') + 1;
|
||||
}
|
||||
name = name.Substring (0, lt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
213
external/api-doc-tools/mdoc/Mono.Documentation/exceptions.cs
vendored
Normal file
213
external/api-doc-tools/mdoc/Mono.Documentation/exceptions.cs
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
//
|
||||
// Mono.Documentation/exceptions.cs
|
||||
//
|
||||
// Authors:
|
||||
// Jonathan Pryor (jonpryor@vt.edu)
|
||||
//
|
||||
// (C) 2008 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
[Flags]
|
||||
public enum ExceptionLocations {
|
||||
Member = 0x0,
|
||||
Assembly = 0x1,
|
||||
DependentAssemblies = 0x2,
|
||||
AddedMembers = 0x4,
|
||||
}
|
||||
|
||||
public class ExceptionSources {
|
||||
internal ExceptionSources (TypeReference exception)
|
||||
{
|
||||
Exception = exception;
|
||||
Sources = new HashSet<MemberReference> ();
|
||||
}
|
||||
|
||||
public TypeReference Exception { get; private set; }
|
||||
internal HashSet<MemberReference> Sources;
|
||||
}
|
||||
|
||||
|
||||
public class ExceptionLookup {
|
||||
|
||||
SlashDocMemberFormatter xdoc = new SlashDocMemberFormatter ();
|
||||
|
||||
// xdoc(MemberRef) -> xdoc(TypeRef) -> ExceptionSource
|
||||
// where ExceptionSource.Exception == xdoc(TypeRef)
|
||||
Dictionary<string, Dictionary<string, ExceptionSources>> db = new Dictionary<string, Dictionary<string, ExceptionSources>> ();
|
||||
|
||||
ExceptionLocations locations;
|
||||
|
||||
public ExceptionLookup (ExceptionLocations locations)
|
||||
{
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public IEnumerable<ExceptionSources> this [MemberReference member] {
|
||||
get {
|
||||
if (member == null)
|
||||
throw new ArgumentNullException ("member");
|
||||
|
||||
var memberDef = member.Resolve ();
|
||||
if (memberDef == null) {
|
||||
ArrayType array = member.DeclaringType as ArrayType;
|
||||
if (array != null && array.Rank > 1) {
|
||||
// Multi-dimensional array; the member is runtime generated,
|
||||
// doesn't "really" exist (in a form that we can resolve),
|
||||
// so we can't do anything further.
|
||||
return new ExceptionSources[0];
|
||||
}
|
||||
throw new NotSupportedException (string.Format (
|
||||
"Unable to resolve member {0}::{1}.",
|
||||
member.DeclaringType.FullName, member.Name));
|
||||
}
|
||||
string memberDecl = xdoc.GetDeclaration (member);
|
||||
Dictionary<string, ExceptionSources> e;
|
||||
if (!db.TryGetValue (memberDecl, out e)) {
|
||||
e = new Dictionary<string, ExceptionSources> ();
|
||||
db.Add (memberDecl, e);
|
||||
var bodies = GetMethodBodies (member);
|
||||
foreach (var body in bodies) {
|
||||
if (body == null)
|
||||
continue;
|
||||
FillExceptions (body, e);
|
||||
}
|
||||
}
|
||||
return e.Values;
|
||||
}
|
||||
}
|
||||
|
||||
MethodBody[] GetMethodBodies (MemberReference member)
|
||||
{
|
||||
if (member is MethodReference) {
|
||||
return new[]{ (((MethodReference) member).Resolve ()).Body };
|
||||
}
|
||||
if (member is PropertyReference) {
|
||||
PropertyDefinition prop = (PropertyDefinition) member;
|
||||
return new[]{
|
||||
prop.GetMethod != null ? prop.GetMethod.Body : null,
|
||||
prop.SetMethod != null ? prop.SetMethod.Body : null,
|
||||
};
|
||||
}
|
||||
if (member is FieldReference)
|
||||
return new MethodBody[]{};
|
||||
if (member is EventReference) {
|
||||
EventDefinition ev = (EventDefinition) member;
|
||||
return new[]{
|
||||
ev.AddMethod != null ? ev.AddMethod.Body : null,
|
||||
ev.InvokeMethod != null ? ev.InvokeMethod.Body : null,
|
||||
ev.RemoveMethod != null ? ev.RemoveMethod.Body : null,
|
||||
};
|
||||
}
|
||||
throw new NotSupportedException ("Unsupported member type: " + member.GetType().FullName);
|
||||
}
|
||||
|
||||
void FillExceptions (MethodBody body, Dictionary<string, ExceptionSources> exceptions)
|
||||
{
|
||||
for (int i = 0; i < body.Instructions.Count; ++i) {
|
||||
Instruction instruction = body.Instructions [i];
|
||||
switch (instruction.OpCode.Code) {
|
||||
case Code.Call:
|
||||
case Code.Callvirt: {
|
||||
if ((locations & ExceptionLocations.Assembly) == 0 &&
|
||||
(locations & ExceptionLocations.DependentAssemblies) == 0)
|
||||
break;
|
||||
MemberReference memberRef = ((MemberReference) instruction.Operand);
|
||||
if (((locations & ExceptionLocations.Assembly) != 0 &&
|
||||
body.Method.DeclaringType.Scope.Name == memberRef.DeclaringType.Scope.Name) ||
|
||||
((locations & ExceptionLocations.DependentAssemblies) != 0 &&
|
||||
body.Method.DeclaringType.Scope.Name != memberRef.DeclaringType.Scope.Name)) {
|
||||
|
||||
IEnumerable<ExceptionSources> memberExceptions = this [memberRef];
|
||||
AddExceptions (body, instruction,
|
||||
memberExceptions.Select (es => es.Exception),
|
||||
memberExceptions.SelectMany (es => es.Sources),
|
||||
exceptions);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Code.Newobj: {
|
||||
MethodReference ctor = (MethodReference) instruction.Operand;
|
||||
if (IsExceptionConstructor (ctor)) {
|
||||
AddExceptions (body, instruction,
|
||||
new TypeReference[]{ctor.DeclaringType},
|
||||
new MemberReference[]{body.Method},
|
||||
exceptions);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddExceptions (MethodBody body, Instruction instruction, IEnumerable<TypeReference> add, IEnumerable<MemberReference> sources,
|
||||
Dictionary<string, ExceptionSources> exceptions)
|
||||
{
|
||||
var handlers = body.ExceptionHandlers.Cast<ExceptionHandler> ()
|
||||
.Where (eh => instruction.Offset >= eh.TryStart.Offset &&
|
||||
instruction.Offset <= eh.TryEnd.Offset);
|
||||
foreach (var ex in add) {
|
||||
if (!handlers.Any (h => IsExceptionCaught (ex, h.CatchType))) {
|
||||
ExceptionSources s;
|
||||
string eName = xdoc.GetDeclaration (ex);
|
||||
if (!exceptions.TryGetValue (eName, out s)) {
|
||||
s = new ExceptionSources (ex);
|
||||
exceptions.Add (eName, s);
|
||||
}
|
||||
foreach (var m in sources)
|
||||
s.Sources.Add (m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsExceptionConstructor (MethodReference ctor)
|
||||
{
|
||||
return GetBases (ctor.DeclaringType)
|
||||
.Any (t => t.FullName == "System.Exception");
|
||||
}
|
||||
|
||||
bool IsExceptionCaught (TypeReference exception, TypeReference catcher)
|
||||
{
|
||||
return GetBases (exception).Select (e => xdoc.GetDeclaration (e))
|
||||
.Union (GetBases (catcher).Select (e => xdoc.GetDeclaration (e)))
|
||||
.Any ();
|
||||
}
|
||||
|
||||
static IEnumerable<TypeReference> GetBases (TypeReference type)
|
||||
{
|
||||
yield return type;
|
||||
TypeDefinition def = type.Resolve ();
|
||||
while (def != null && def.BaseType != null) {
|
||||
yield return def.BaseType;
|
||||
def = def.BaseType.Resolve ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
external/api-doc-tools/mdoc/Mono.Documentation/frameworksbootstrapper.cs
vendored
Normal file
56
external/api-doc-tools/mdoc/Mono.Documentation/frameworksbootstrapper.cs
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// Command to preserve member documentation for types that are changing in a subsequent version
|
||||
// By Joel Martinez <joel.martinez@xamarin.com
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Mono.Options;
|
||||
|
||||
namespace Mono.Documentation
|
||||
{
|
||||
public class MDocFrameworksBootstrapper : MDocCommand
|
||||
{
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
args = args.Skip (1);
|
||||
if (args.Count () != 1)
|
||||
Error ("Need to supply a single directory, which contain folders that represent frameworks.");
|
||||
|
||||
string frameworkPath = args.Single ();
|
||||
int slashOffset = frameworkPath.EndsWith (Path.DirectorySeparatorChar.ToString (), StringComparison.InvariantCultureIgnoreCase) ? 0 : 1;
|
||||
|
||||
if (!Directory.Exists(frameworkPath))
|
||||
Error ($"Path not found: {frameworkPath}");
|
||||
|
||||
var data = Directory.GetDirectories (frameworkPath)
|
||||
.Select (d => new {
|
||||
Path = d.Substring (frameworkPath.Length + slashOffset, d.Length - frameworkPath.Length - slashOffset),
|
||||
Name = Path.GetFileName(d)
|
||||
}).ToArray();
|
||||
|
||||
foreach (var d in data)
|
||||
Console.WriteLine (d.Name);
|
||||
|
||||
var doc = new XDocument (
|
||||
new XElement("Frameworks",
|
||||
data.Select(d => new XElement(
|
||||
"Framework",
|
||||
new XAttribute("Name", d.Name),
|
||||
new XAttribute("Source", d.Path),
|
||||
new XElement("assemblySearchPath", Path.Combine("dependencies", d.Name)))))
|
||||
);
|
||||
|
||||
var configPath = Path.Combine (frameworkPath, "frameworks.xml");
|
||||
var settings = new XmlWriterSettings { Indent = true };
|
||||
using (var writer = XmlWriter.Create (configPath, settings)) {
|
||||
doc.WriteTo (writer);
|
||||
}
|
||||
|
||||
Console.WriteLine ($"Framework configuration file written to {configPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
66
external/api-doc-tools/mdoc/Mono.Documentation/index.cs
vendored
Normal file
66
external/api-doc-tools/mdoc/Mono.Documentation/index.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// index.cs
|
||||
// Index maker (both normal and Lucene-based)
|
||||
//
|
||||
// Authors:
|
||||
// Jérémie Laval <jeremie dot laval at xamarin dot com>
|
||||
//
|
||||
// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Options;
|
||||
using Monodoc;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class MDocIndex : MDocCommand {
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
string rootPath = null;
|
||||
|
||||
var options = new OptionSet () {
|
||||
{ "r=|root=", "Specify which documentation root to use. Default is $libdir/monodoc", v => rootPath = v },
|
||||
};
|
||||
|
||||
var extra = Parse (options, args, "index",
|
||||
"[OPTIONS]+ ACTION",
|
||||
"Create Monodoc indexes depending on ACTION. Possible values are \"tree\" or \"search\" for, respectively, mdoc tree and lucene search");
|
||||
if (extra == null)
|
||||
return;
|
||||
|
||||
var root = string.IsNullOrEmpty (rootPath) ? RootTree.LoadTree () : RootTree.LoadTree (rootPath);
|
||||
|
||||
foreach (var action in extra) {
|
||||
switch (action) {
|
||||
case "tree":
|
||||
root.GenerateIndex ();
|
||||
break;
|
||||
case "search":
|
||||
root.GenerateSearchIndex ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user