You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
182
external/api-doc-tools/mdoc/Mono.Documentation/mdoc.cs
vendored
Normal file
182
external/api-doc-tools/mdoc/Mono.Documentation/mdoc.cs
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
// Part of the mdoc(7) suite of tools.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Mono.Options;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class MDoc {
|
||||
|
||||
private static bool debug;
|
||||
|
||||
private static void Main (string[] args)
|
||||
{
|
||||
MDoc d = new MDoc ();
|
||||
try {
|
||||
d.Run (args);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (debug) {
|
||||
Console.Error.WriteLine ("mdoc: {0}", e.ToString ());
|
||||
}
|
||||
else {
|
||||
Console.Error.WriteLine ("mdoc: {0}", e.Message);
|
||||
}
|
||||
Console.Error.WriteLine ("See `mdoc help' for more information or use --debug to diagnose.");
|
||||
Environment.ExitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int verbosity = 2;
|
||||
|
||||
internal Dictionary<string, MDocCommand> subcommands;
|
||||
|
||||
private void Run (string[] args)
|
||||
{
|
||||
subcommands = new Dictionary<string, MDocCommand> () {
|
||||
{ "assemble", new MDocAssembler () },
|
||||
{ "dump-tree", new MDocTreeDumper () },
|
||||
{ "export-html", new MDocToHtmlConverter () },
|
||||
{ "export-html-webdoc", new MDocExportWebdocHtml () },
|
||||
{ "export-msxdoc", new MDocToMSXDocConverter () },
|
||||
{ "help", new MDocHelpCommand (this) },
|
||||
{ "update", new MDocUpdater () },
|
||||
{ "update-ecma-xml", new MDocUpdateEcmaXml () },
|
||||
{ "validate", new MDocValidator () },
|
||||
{ "index", new MDocIndex () },
|
||||
{ "fx-bootstrap", new MDocFrameworksBootstrapper () }
|
||||
};
|
||||
|
||||
bool showVersion = false;
|
||||
bool showHelp = false;
|
||||
var p = new OptionSet () {
|
||||
{ "version", v => showVersion = v != null },
|
||||
{ "v:", (int? v) => verbosity = v.HasValue ? v.Value : verbosity+1 },
|
||||
{ "debug", v => debug = v != null },
|
||||
{ "h|?|help", v => showHelp = v != null },
|
||||
new ResponseFileSource (),
|
||||
};
|
||||
|
||||
var extra = p.Parse (args);
|
||||
|
||||
if (showVersion) {
|
||||
Console.WriteLine ("mdoc {0}", Consts.MonoVersion);
|
||||
return;
|
||||
}
|
||||
if (extra.Count == 0) {
|
||||
Console.WriteLine ("Use `mdoc help' for usage.");
|
||||
return;
|
||||
}
|
||||
if (showHelp) {
|
||||
extra.Add ("--help");
|
||||
}
|
||||
switch (extra [0]) {
|
||||
case "x-msitomsx":
|
||||
new MsidocToMsxdocConverter ().Run (extra);
|
||||
break;
|
||||
default:
|
||||
GetCommand (extra [0]).Run (extra);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal MDocCommand GetCommand (string command)
|
||||
{
|
||||
MDocCommand h;
|
||||
if (!subcommands.TryGetValue (command, out h)) {
|
||||
Error ("Unknown command: {0}.", command);
|
||||
}
|
||||
h.TraceLevel = (TraceLevel) verbosity;
|
||||
h.DebugOutput = debug;
|
||||
return h;
|
||||
}
|
||||
|
||||
private static void Error (string format, params object[] args)
|
||||
{
|
||||
throw new Exception (string.Format (format, args));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class MDocCommand {
|
||||
|
||||
public TraceLevel TraceLevel { get; set; }
|
||||
public bool DebugOutput { get; set; }
|
||||
|
||||
public abstract void Run (IEnumerable<string> args);
|
||||
|
||||
protected List<string> Parse (OptionSet p, IEnumerable<string> args,
|
||||
string command, string prototype, string description)
|
||||
{
|
||||
bool showHelp = false;
|
||||
p.Add ("h|?|help",
|
||||
"Show this message and exit.",
|
||||
v => showHelp = v != null );
|
||||
|
||||
List<string> extra = null;
|
||||
if (args != null) {
|
||||
extra = p.Parse (args.Skip (1));
|
||||
}
|
||||
if (args == null || showHelp) {
|
||||
Console.WriteLine ("usage: mdoc {0} {1}",
|
||||
args == null ? command : args.First(), prototype);
|
||||
Console.WriteLine ();
|
||||
Console.WriteLine (description);
|
||||
Console.WriteLine ();
|
||||
Console.WriteLine ("Available Options:");
|
||||
p.WriteOptionDescriptions (Console.Out);
|
||||
return null;
|
||||
}
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void Error (string format, params object[] args)
|
||||
{
|
||||
throw new Exception (string.Format (format, args));
|
||||
}
|
||||
|
||||
public void Message (TraceLevel level, string format, params object[] args)
|
||||
{
|
||||
if ((int) level > (int) TraceLevel)
|
||||
return;
|
||||
if (level == TraceLevel.Error)
|
||||
Console.Error.WriteLine (format, args);
|
||||
else
|
||||
Console.WriteLine (format, args);
|
||||
}
|
||||
}
|
||||
|
||||
class MDocHelpCommand : MDocCommand {
|
||||
|
||||
MDoc instance;
|
||||
|
||||
public MDocHelpCommand (MDoc instance)
|
||||
{
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
if (args != null && args.Count() > 1) {
|
||||
foreach (var arg in args.Skip (1)) {
|
||||
instance.GetCommand (arg).Run (new string[]{arg, "--help"});
|
||||
}
|
||||
return;
|
||||
}
|
||||
Message (TraceLevel.Warning,
|
||||
"usage: mdoc COMMAND [OPTIONS]\n" +
|
||||
"Use `mdoc help COMMAND' for help on a specific command.\n" +
|
||||
"\n" +
|
||||
"Available commands:\n\n " +
|
||||
string.Join ("\n ", instance.subcommands.Keys.OrderBy (v => v).ToArray()) +
|
||||
"\n\n" +
|
||||
"mdoc is a tool for documentation management.\n" +
|
||||
"For additional information, see http://www.mono-project.com/"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
external/api-doc-tools/mdoc/Mono.Documentation/monodocer.cs.REMOVED.git-id
vendored
Normal file
1
external/api-doc-tools/mdoc/Mono.Documentation/monodocer.cs.REMOVED.git-id
vendored
Normal file
@@ -0,0 +1 @@
|
||||
081657c59dd301130e3b08a1e6a4cc997f17b1d6
|
496
external/api-doc-tools/mdoc/Mono.Documentation/monodocs2html.cs
vendored
Normal file
496
external/api-doc-tools/mdoc/Mono.Documentation/monodocs2html.cs
vendored
Normal file
@@ -0,0 +1,496 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
|
||||
using Mono.Documentation;
|
||||
using Mono.Options;
|
||||
|
||||
[assembly: AssemblyTitle("Monodocs-to-HTML")]
|
||||
[assembly: AssemblyCopyright("Copyright (c) 2004 Joshua Tauberer <tauberer@for.net>, released under the GPL.")]
|
||||
[assembly: AssemblyDescription("Convert Monodoc XML documentation to static HTML.")]
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class MDocToHtmlConverterOptions {
|
||||
public string dest;
|
||||
public string ext = "html";
|
||||
public string onlytype;
|
||||
public string template;
|
||||
public bool dumptemplate;
|
||||
public bool forceUpdate;
|
||||
public HashSet<string> versions = new HashSet<string> ();
|
||||
}
|
||||
|
||||
class MDocToHtmlConverter : MDocCommand {
|
||||
|
||||
static Dictionary<string, string[]> profiles = new Dictionary<string, string[]>() {
|
||||
// FxVersions----- VsVersions-----
|
||||
{ "monotouch", new[]{"0.0.0.0", "2.0.5.0" } },
|
||||
{ "net_1_0", new[]{"1.0.3300.0", "7.0.3300.0"} },
|
||||
{ "net_1_1", new[]{"1.0.5000.0", "7.0.5000.0"} },
|
||||
{ "net_2_0", new[]{"2.0.0.0", "8.0.0.0"} },
|
||||
{ "net_3_0", new[]{"2.0.0.0", "3.0.0.0", "8.0.0.0"} },
|
||||
{ "net_3_5", new[]{"2.0.0.0", "3.0.0.0", "3.5.0.0", "8.0.0.0"} },
|
||||
{ "net_4_0", new[]{"4.0.0.0" } },
|
||||
{ "silverlight", new[]{"2.0.5.0", "9.0.0.0"} },
|
||||
};
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
opts = new MDocToHtmlConverterOptions ();
|
||||
var p = new OptionSet () {
|
||||
{ "default-template",
|
||||
"Writes the default XSLT to stdout.",
|
||||
v => opts.dumptemplate = v != null },
|
||||
{ "ext=",
|
||||
"The file {EXTENSION} to use for created files. "+
|
||||
"This defaults to \"html\".",
|
||||
v => opts.ext = v },
|
||||
{ "force-update",
|
||||
"Always generate new files. If not specified, will only generate a " +
|
||||
"new file if the source .xml file is newer than the current output " +
|
||||
"file.",
|
||||
v => opts.forceUpdate = v != null },
|
||||
{ "o|out=",
|
||||
"The {DIRECTORY} to place the generated files and directories.",
|
||||
v => opts.dest = v },
|
||||
{ "template=",
|
||||
"An XSLT {FILE} to use to generate the created " +
|
||||
"files.If not specified, uses the template generated by " +
|
||||
"--default-template.",
|
||||
v => opts.template = v },
|
||||
{ "with-profile=",
|
||||
"The .NET {PROFILE} to generate documentation for. This is " +
|
||||
"equivalent to using --with-version for all of the " +
|
||||
"versions that a profile uses. Valid profiles are:\n " +
|
||||
string.Join ("\n ", profiles.Keys.OrderBy (v => v).ToArray ()),
|
||||
v => {
|
||||
if (!profiles.ContainsKey (v))
|
||||
throw new ArgumentException (string.Format ("Unsupported profile '{0}'.", v));
|
||||
foreach (var ver in profiles [v.ToLowerInvariant ()])
|
||||
opts.versions.Add (ver);
|
||||
} },
|
||||
{ "with-version=",
|
||||
"The assembly {VERSION} to generate documentation for. This allows " +
|
||||
"display of a subset of types/members that correspond to the given " +
|
||||
"assembly version. May be specified multiple times. " +
|
||||
"If not specified, all versions are displayed.",
|
||||
v => opts.versions.Add (v) }
|
||||
};
|
||||
List<string> extra = Parse (p, args, "export-html",
|
||||
"[OPTIONS]+ DIRECTORIES",
|
||||
"Export mdoc documentation within DIRECTORIES to HTML.");
|
||||
if (extra == null)
|
||||
return;
|
||||
if (opts.dumptemplate)
|
||||
DumpTemplate ();
|
||||
else
|
||||
ProcessDirectories (extra);
|
||||
opts.onlytype = "ignore"; // remove warning about unused member
|
||||
}
|
||||
|
||||
static MDocToHtmlConverterOptions opts;
|
||||
|
||||
void ProcessDirectories (List<string> sourceDirectories)
|
||||
{
|
||||
if (sourceDirectories.Count == 0 || opts.dest == null || opts.dest == "")
|
||||
throw new ApplicationException("The source and dest options must be specified.");
|
||||
|
||||
Directory.CreateDirectory(opts.dest);
|
||||
|
||||
// Load the stylesheets, overview.xml, and resolver
|
||||
|
||||
XslCompiledTransform overviewxsl = LoadTransform("overview.xsl", sourceDirectories);
|
||||
XslCompiledTransform stylesheet = LoadTransform("stylesheet.xsl", sourceDirectories);
|
||||
XslCompiledTransform template;
|
||||
if (opts.template == null) {
|
||||
template = LoadTransform("defaulttemplate.xsl", sourceDirectories);
|
||||
} else {
|
||||
try {
|
||||
XmlDocument templatexsl = new XmlDocument();
|
||||
templatexsl.Load(opts.template);
|
||||
template = new XslCompiledTransform (DebugOutput);
|
||||
template.Load(templatexsl);
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationException("There was an error loading " + opts.template, e);
|
||||
}
|
||||
}
|
||||
|
||||
XmlDocument overview = GetOverview (sourceDirectories);
|
||||
|
||||
ArrayList extensions = GetExtensionMethods (overview);
|
||||
|
||||
// Create the master page
|
||||
XsltArgumentList overviewargs = new XsltArgumentList();
|
||||
overviewargs.AddParam("Index", "", overview.CreateNavigator ());
|
||||
|
||||
var regenIndex = ShouldRegenIndexes (opts, overview, sourceDirectories);
|
||||
if (regenIndex) {
|
||||
overviewargs.AddParam("ext", "", opts.ext);
|
||||
overviewargs.AddParam("basepath", "", "./");
|
||||
Generate(overview, overviewxsl, overviewargs, opts.dest + "/index." + opts.ext, template, sourceDirectories);
|
||||
overviewargs.RemoveParam("basepath", "");
|
||||
}
|
||||
overviewargs.AddParam("basepath", "", "../");
|
||||
|
||||
// Create the namespace & type pages
|
||||
|
||||
XsltArgumentList typeargs = new XsltArgumentList();
|
||||
typeargs.AddParam("ext", "", opts.ext);
|
||||
typeargs.AddParam("basepath", "", "../");
|
||||
typeargs.AddParam("Index", "", overview.CreateNavigator ());
|
||||
|
||||
foreach (XmlElement ns in overview.SelectNodes("Overview/Types/Namespace")) {
|
||||
string nsname = ns.GetAttribute("Name");
|
||||
|
||||
if (opts.onlytype != null && !opts.onlytype.StartsWith(nsname + "."))
|
||||
continue;
|
||||
|
||||
System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(opts.dest + "/" + nsname);
|
||||
if (!d.Exists) d.Create();
|
||||
|
||||
// Create the NS page
|
||||
string nsDest = opts.dest + "/" + nsname + "/index." + opts.ext;
|
||||
if (regenIndex) {
|
||||
overviewargs.AddParam("namespace", "", nsname);
|
||||
Generate(overview, overviewxsl, overviewargs, nsDest, template, sourceDirectories);
|
||||
overviewargs.RemoveParam("namespace", "");
|
||||
}
|
||||
|
||||
foreach (XmlElement ty in ns.SelectNodes("Type")) {
|
||||
string typename, typefile, destfile;
|
||||
GetTypePaths (opts, ty, out typename, out typefile, out destfile);
|
||||
|
||||
if (DestinationIsNewer (typefile, destfile))
|
||||
// target already exists, and is newer. why regenerate?
|
||||
continue;
|
||||
|
||||
XmlDocument typexml = new XmlDocument();
|
||||
typexml.Load(typefile);
|
||||
PreserveMembersInVersions (typexml);
|
||||
if (extensions != null) {
|
||||
DocLoader loader = CreateDocLoader (overview);
|
||||
XmlDocUtils.AddExtensionMethods (typexml, extensions, loader);
|
||||
}
|
||||
|
||||
Console.WriteLine(nsname + "." + typename);
|
||||
|
||||
Generate(typexml, stylesheet, typeargs, destfile, template, sourceDirectories);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList GetExtensionMethods (XmlDocument doc)
|
||||
{
|
||||
XmlNodeList extensions = doc.SelectNodes ("/Overview/ExtensionMethods/*");
|
||||
if (extensions.Count == 0)
|
||||
return null;
|
||||
ArrayList r = new ArrayList (extensions.Count);
|
||||
foreach (XmlNode n in extensions)
|
||||
r.Add (n);
|
||||
return r;
|
||||
}
|
||||
|
||||
static bool ShouldRegenIndexes (MDocToHtmlConverterOptions opts, XmlDocument overview, List<string> sourceDirectories)
|
||||
{
|
||||
string overviewDest = opts.dest + "/index." + opts.ext;
|
||||
if (sourceDirectories.Any (
|
||||
d => !DestinationIsNewer (Path.Combine (d, "index.xml"), overviewDest)))
|
||||
return true;
|
||||
|
||||
foreach (XmlElement type in overview.SelectNodes("Overview/Types/Namespace/Type")) {
|
||||
string _, srcfile, destfile;
|
||||
GetTypePaths (opts, type, out _, out srcfile, out destfile);
|
||||
|
||||
if (srcfile == null || destfile == null)
|
||||
continue;
|
||||
if (DestinationIsNewer (srcfile, destfile))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void GetTypePaths (MDocToHtmlConverterOptions opts, XmlElement type, out string typename, out string srcfile, out string destfile)
|
||||
{
|
||||
srcfile = null;
|
||||
destfile = null;
|
||||
|
||||
string nsname = type.ParentNode.Attributes ["Name"].Value;
|
||||
string typefilebase = type.GetAttribute("Name");
|
||||
string sourceDir = type.GetAttribute("SourceDirectory");
|
||||
typename = type.GetAttribute("DisplayName");
|
||||
if (typename.Length == 0)
|
||||
typename = typefilebase;
|
||||
|
||||
if (opts.onlytype != null && !(nsname + "." + typename).StartsWith(opts.onlytype))
|
||||
return;
|
||||
|
||||
srcfile = CombinePath (sourceDir, nsname, typefilebase + ".xml");
|
||||
if (srcfile == null)
|
||||
return;
|
||||
|
||||
destfile = CombinePath (opts.dest, nsname, typefilebase + "." + opts.ext);
|
||||
}
|
||||
|
||||
private static void DumpTemplate() {
|
||||
Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("defaulttemplate.xsl");
|
||||
Stream o = Console.OpenStandardOutput ();
|
||||
byte[] buf = new byte[1024];
|
||||
int r;
|
||||
while ((r = s.Read (buf, 0, buf.Length)) > 0) {
|
||||
o.Write (buf, 0, r);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Generate(XmlDocument source, XslCompiledTransform transform, XsltArgumentList args, string output, XslCompiledTransform template, List<string> sourceDirectories) {
|
||||
using (TextWriter textwriter = new StreamWriter(new FileStream(output, FileMode.Create))) {
|
||||
XmlTextWriter writer = new XmlTextWriter(textwriter);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
writer.Indentation = 2;
|
||||
writer.IndentChar = ' ';
|
||||
|
||||
try {
|
||||
var intermediate = new StringBuilder ();
|
||||
transform.Transform (
|
||||
new XmlNodeReader (source),
|
||||
args,
|
||||
XmlWriter.Create (intermediate, transform.OutputSettings),
|
||||
new ManifestResourceResolver(sourceDirectories.ToArray ()));
|
||||
template.Transform (
|
||||
XmlReader.Create (new StringReader (intermediate.ToString ())),
|
||||
new XsltArgumentList (),
|
||||
new XhtmlWriter (writer),
|
||||
null);
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationException("An error occured while generating " + output, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private XslCompiledTransform LoadTransform(string name, List<string> sourceDirectories) {
|
||||
try {
|
||||
XmlDocument xsl = new XmlDocument();
|
||||
xsl.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream(name));
|
||||
|
||||
if (name == "overview.xsl") {
|
||||
// bit of a hack. overview needs the templates in stylesheet
|
||||
// for doc formatting, and rather than write a resolver, I'll
|
||||
// just do the import for it.
|
||||
|
||||
XmlNode importnode = xsl.DocumentElement.SelectSingleNode("*[name()='xsl:include']");
|
||||
xsl.DocumentElement.RemoveChild(importnode);
|
||||
|
||||
XmlDocument xsl2 = new XmlDocument();
|
||||
xsl2.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("stylesheet.xsl"));
|
||||
foreach (XmlNode node in xsl2.DocumentElement.ChildNodes)
|
||||
xsl.DocumentElement.AppendChild(xsl.ImportNode(node, true));
|
||||
}
|
||||
|
||||
XslCompiledTransform t = new XslCompiledTransform (DebugOutput);
|
||||
t.Load (
|
||||
xsl,
|
||||
XsltSettings.TrustedXslt,
|
||||
new ManifestResourceResolver (sourceDirectories.ToArray ()));
|
||||
|
||||
return t;
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationException("Error loading " + name + " from internal resource", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static DocLoader CreateDocLoader (XmlDocument overview)
|
||||
{
|
||||
Hashtable docs = new Hashtable ();
|
||||
DocLoader loader = delegate (string s) {
|
||||
XmlDocument d = null;
|
||||
if (!docs.ContainsKey (s)) {
|
||||
foreach (XmlNode n in overview.SelectNodes ("//Type")) {
|
||||
string ns = n.ParentNode.Attributes ["Name"].Value;
|
||||
string t = n.Attributes ["Name"].Value;
|
||||
string sd = n.Attributes ["SourceDirectory"].Value;
|
||||
if (s == ns + "." + t.Replace ("+", ".")) {
|
||||
string f = CombinePath (sd, ns, t + ".xml");
|
||||
if (File.Exists (f)) {
|
||||
d = new XmlDocument ();
|
||||
d.Load (f);
|
||||
}
|
||||
docs.Add (s, d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
d = (XmlDocument) docs [s];
|
||||
return d;
|
||||
};
|
||||
return loader;
|
||||
}
|
||||
|
||||
static string CombinePath (params string[] paths)
|
||||
{
|
||||
if (paths == null)
|
||||
return null;
|
||||
if (paths.Length == 1)
|
||||
return paths [0];
|
||||
var path = Path.Combine (paths [0], paths [1]);
|
||||
for (int i = 2; i < paths.Length; ++i)
|
||||
path = Path.Combine (path, paths [i]);
|
||||
return path;
|
||||
}
|
||||
|
||||
private XmlDocument GetOverview (IEnumerable<string> directories)
|
||||
{
|
||||
var index = new XmlDocument ();
|
||||
|
||||
var overview = index.CreateElement ("Overview");
|
||||
var assemblies= index.CreateElement ("Assemblies");
|
||||
var types = index.CreateElement ("Types");
|
||||
var ems = index.CreateElement ("ExtensionMethods");
|
||||
|
||||
index.AppendChild (overview);
|
||||
overview.AppendChild (assemblies);
|
||||
overview.AppendChild (types);
|
||||
overview.AppendChild (ems);
|
||||
|
||||
bool first = true;
|
||||
|
||||
foreach (var dir in directories) {
|
||||
var indexFile = Path.Combine (dir, "index.xml");
|
||||
try {
|
||||
var doc = new XmlDocument ();
|
||||
doc.Load (indexFile);
|
||||
if (first) {
|
||||
var c = doc.SelectSingleNode ("/Overview/Copyright");
|
||||
var t = doc.SelectSingleNode ("/Overview/Title");
|
||||
var r = doc.SelectSingleNode ("/Overview/Remarks");
|
||||
if (c != null && t != null && r != null) {
|
||||
var e = index.CreateElement ("Copyright");
|
||||
e.InnerXml = c.InnerXml;
|
||||
overview.AppendChild (e);
|
||||
|
||||
e = index.CreateElement ("Title");
|
||||
e.InnerXml = t.InnerXml;
|
||||
overview.AppendChild (e);
|
||||
|
||||
e = index.CreateElement ("Remarks");
|
||||
e.InnerXml = r.InnerXml;
|
||||
overview.AppendChild (e);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
AddAssemblies (assemblies, doc);
|
||||
AddTypes (types, doc, dir);
|
||||
AddChildren (ems, doc, "/Overview/ExtensionMethods");
|
||||
}
|
||||
catch (Exception e) {
|
||||
Message (TraceLevel.Warning, "Could not load documentation index '{0}': {1}",
|
||||
indexFile, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
static void AddChildren (XmlNode dest, XmlDocument source, string path)
|
||||
{
|
||||
var n = source.SelectSingleNode (path);
|
||||
if (n != null)
|
||||
foreach (XmlNode c in n.ChildNodes)
|
||||
dest.AppendChild (dest.OwnerDocument.ImportNode (c, true));
|
||||
}
|
||||
|
||||
static void AddAssemblies (XmlNode dest, XmlDocument source)
|
||||
{
|
||||
foreach (XmlNode asm in source.SelectNodes ("/Overview/Assemblies/Assembly")) {
|
||||
var n = asm.Attributes ["Name"].Value;
|
||||
var v = asm.Attributes ["Version"].Value;
|
||||
if (dest.SelectSingleNode (string.Format ("Assembly[@Name='{0}'][@Value='{1}']", n, v)) == null) {
|
||||
dest.AppendChild (dest.OwnerDocument.ImportNode (asm, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AddTypes (XmlNode dest, XmlDocument source, string sourceDirectory)
|
||||
{
|
||||
var types = source.SelectSingleNode ("/Overview/Types");
|
||||
if (types == null)
|
||||
return;
|
||||
foreach (XmlNode ns in types.ChildNodes) {
|
||||
var n = ns.Attributes ["Name"].Value;
|
||||
var nsd = dest.SelectSingleNode (string.Format ("Namespace[@Name='{0}']", n));
|
||||
if (nsd == null) {
|
||||
nsd = dest.OwnerDocument.CreateElement ("Namespace");
|
||||
AddAttribute (nsd, "Name", n);
|
||||
dest.AppendChild (nsd);
|
||||
}
|
||||
foreach (XmlNode t in ns.ChildNodes) {
|
||||
if (!TypeInVersions (sourceDirectory, n, t))
|
||||
continue;
|
||||
var c = dest.OwnerDocument.ImportNode (t, true);
|
||||
AddAttribute (c, "SourceDirectory", sourceDirectory);
|
||||
nsd.AppendChild (c);
|
||||
}
|
||||
if (nsd.ChildNodes.Count == 0)
|
||||
dest.RemoveChild (nsd);
|
||||
}
|
||||
}
|
||||
|
||||
static bool TypeInVersions (string sourceDirectory, string ns, XmlNode type)
|
||||
{
|
||||
if (opts.versions.Count == 0)
|
||||
return true;
|
||||
var file = Path.Combine (Path.Combine (sourceDirectory, ns), type.Attributes ["Name"].Value + ".xml");
|
||||
if (!File.Exists (file))
|
||||
return false;
|
||||
XPathDocument doc;
|
||||
using (var s = File.OpenText (file))
|
||||
doc = new XPathDocument (s);
|
||||
return MemberInVersions (doc.CreateNavigator ().SelectSingleNode ("/Type"));
|
||||
}
|
||||
|
||||
static bool MemberInVersions (XPathNavigator nav)
|
||||
{
|
||||
return nav.Select ("AssemblyInfo/AssemblyVersion")
|
||||
.Cast<object> ()
|
||||
.Any (v => opts.versions.Contains (v.ToString ()));
|
||||
}
|
||||
|
||||
static void AddAttribute (XmlNode self, string name, string value)
|
||||
{
|
||||
var a = self.OwnerDocument.CreateAttribute (name);
|
||||
a.Value = value;
|
||||
self.Attributes.Append (a);
|
||||
}
|
||||
|
||||
private static bool DestinationIsNewer (string source, string dest)
|
||||
{
|
||||
return !opts.forceUpdate && File.Exists (dest) &&
|
||||
File.GetLastWriteTime (source) < File.GetLastWriteTime (dest);
|
||||
}
|
||||
|
||||
private static void PreserveMembersInVersions (XmlDocument doc)
|
||||
{
|
||||
if (opts.versions.Count == 0)
|
||||
return;
|
||||
var remove = new List<XmlNode>();
|
||||
foreach (XmlNode m in doc.SelectNodes ("/Type/Members/Member")) {
|
||||
if (!MemberInVersions (m.CreateNavigator ()))
|
||||
remove.Add (m);
|
||||
}
|
||||
XmlNode members = doc.SelectSingleNode ("/Type/Members");
|
||||
foreach (var m in remove)
|
||||
members.RemoveChild (m);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
212
external/api-doc-tools/mdoc/Mono.Documentation/monodocs2slashdoc.cs
vendored
Normal file
212
external/api-doc-tools/mdoc/Mono.Documentation/monodocs2slashdoc.cs
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
using Monodoc;
|
||||
using Mono.Options;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
public class MDocToMSXDocConverter : MDocCommand {
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
string file = null;
|
||||
var p = new OptionSet () {
|
||||
{ "o|out=",
|
||||
"The XML {FILE} to generate.\n" +
|
||||
"If not specified, will create a set of files in the curent directory " +
|
||||
"based on the //AssemblyInfo/AssemblyName values within the documentation.\n" +
|
||||
"Use '-' to write to standard output.",
|
||||
v => file = v },
|
||||
};
|
||||
List<string> directories = Parse (p, args, "export-slashdoc",
|
||||
"[OPTIONS]+ DIRECTORIES",
|
||||
"Export mdoc(5) documentation within DIRECTORIES into \n" +
|
||||
"Microsoft XML Documentation format files.");
|
||||
if (directories == null)
|
||||
return;
|
||||
Run (file, directories);
|
||||
}
|
||||
|
||||
public static void Run (string file, IEnumerable<string> dirs)
|
||||
{
|
||||
Dictionary<string, XmlElement> outputfiles = new Dictionary<string, XmlElement> ();
|
||||
|
||||
XmlDocument nsSummaries = new XmlDocument();
|
||||
nsSummaries.LoadXml("<namespaces/>");
|
||||
|
||||
foreach (string dir in dirs)
|
||||
Process (dir, outputfiles, nsSummaries, file == null);
|
||||
|
||||
if (outputfiles.Count > 0 && file != null) {
|
||||
List<string> files = new List<string> (outputfiles.Keys);
|
||||
files.Sort ();
|
||||
XmlDocument d = new XmlDocument ();
|
||||
d.AppendChild (d.CreateElement ("doc"));
|
||||
d.FirstChild.AppendChild (
|
||||
d.ImportNode (outputfiles [files [0]].SelectSingleNode ("/doc/assembly"), true));
|
||||
XmlElement members = d.CreateElement ("members");
|
||||
d.FirstChild.AppendChild (members);
|
||||
foreach (string f in files) {
|
||||
XmlElement from = (XmlElement) outputfiles [f];
|
||||
foreach (XmlNode n in from.SelectNodes ("/doc/members/*"))
|
||||
members.AppendChild (d.ImportNode (n, true));
|
||||
}
|
||||
using (TextWriter tw = file == "-" ? Console.Out : new StreamWriter (file))
|
||||
WriteXml (d.DocumentElement, tw);
|
||||
return;
|
||||
}
|
||||
|
||||
// Write out each of the assembly documents
|
||||
foreach (string assemblyName in outputfiles.Keys) {
|
||||
XmlElement members = (XmlElement)outputfiles[assemblyName];
|
||||
Console.WriteLine(assemblyName + ".xml");
|
||||
using(StreamWriter sw = new StreamWriter(assemblyName + ".xml")) {
|
||||
WriteXml(members.OwnerDocument.DocumentElement, sw);
|
||||
}
|
||||
}
|
||||
|
||||
// Write out a namespace summaries file.
|
||||
Console.WriteLine("NamespaceSummaries.xml");
|
||||
using(StreamWriter writer = new StreamWriter("NamespaceSummaries.xml")) {
|
||||
WriteXml(nsSummaries.DocumentElement, writer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Process (string basepath, Dictionary<string, XmlElement> outputfiles, XmlDocument nsSummaries, bool implicitFiles)
|
||||
{
|
||||
if (System.Environment.CurrentDirectory == System.IO.Path.GetFullPath(basepath) && implicitFiles) {
|
||||
Console.WriteLine("Don't run this tool from your documentation directory, since some files could be accidentally overwritten.");
|
||||
return;
|
||||
}
|
||||
|
||||
XmlDocument index_doc = new XmlDocument();
|
||||
index_doc.Load(Path.Combine(basepath, "index.xml"));
|
||||
XmlElement index = index_doc.DocumentElement;
|
||||
|
||||
foreach (XmlElement assmbly in index.SelectNodes("Assemblies/Assembly")) {
|
||||
string assemblyName = assmbly.GetAttribute("Name");
|
||||
if (outputfiles.ContainsKey (assemblyName))
|
||||
continue;
|
||||
XmlDocument output = new XmlDocument();
|
||||
XmlElement output_root = output.CreateElement("doc");
|
||||
output.AppendChild(output_root);
|
||||
|
||||
XmlElement output_assembly = output.CreateElement("assembly");
|
||||
output_root.AppendChild(output_assembly);
|
||||
XmlElement output_assembly_name = output.CreateElement("name");
|
||||
output_assembly.AppendChild(output_assembly_name);
|
||||
output_assembly_name.InnerText = assemblyName;
|
||||
|
||||
XmlElement members = output.CreateElement("members");
|
||||
output_root.AppendChild(members);
|
||||
|
||||
outputfiles.Add (assemblyName, members);
|
||||
}
|
||||
|
||||
foreach (XmlElement nsnode in index.SelectNodes("Types/Namespace")) {
|
||||
string ns = nsnode.GetAttribute("Name");
|
||||
foreach (XmlElement typedoc in nsnode.SelectNodes("Type")) {
|
||||
string typename = typedoc.GetAttribute("Name");
|
||||
XmlDocument type = new XmlDocument();
|
||||
type.Load(Path.Combine(Path.Combine(basepath, ns), typename) + ".xml");
|
||||
|
||||
string assemblyname = type.SelectSingleNode("Type/AssemblyInfo/AssemblyName").InnerText;
|
||||
XmlElement members = outputfiles [assemblyname];
|
||||
if (members == null) continue; // assembly is strangely not listed in the index
|
||||
|
||||
CreateMember (GetCref (type.DocumentElement), type.DocumentElement, members);
|
||||
|
||||
foreach (XmlElement memberdoc in type.SelectNodes("Type/Members/Member")) {
|
||||
string name = GetCref (memberdoc);
|
||||
CreateMember(name, memberdoc, members);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (XmlElement nsnode in index.SelectNodes("Types/Namespace")) {
|
||||
AddNamespaceSummary(nsSummaries, basepath, nsnode.GetAttribute("Name"));
|
||||
}
|
||||
}
|
||||
|
||||
static string GetCref (XmlElement member)
|
||||
{
|
||||
string typeName = XmlDocUtils.ToEscapedTypeName (member.SelectSingleNode("/Type/@FullName").InnerText);
|
||||
if (member.Name == "Type")
|
||||
return "T:" + typeName;
|
||||
string memberType = member.SelectSingleNode("MemberType").InnerText;
|
||||
switch (memberType) {
|
||||
case "Constructor":
|
||||
return "C:" + typeName + MakeArgs(member);
|
||||
case "Event":
|
||||
return "E:" + typeName + "." + XmlDocUtils.ToEscapedMemberName (member.GetAttribute("MemberName"));
|
||||
case "Field":
|
||||
return "F:" + typeName + "." + XmlDocUtils.ToEscapedMemberName (member.GetAttribute("MemberName"));
|
||||
case "Method": {
|
||||
string name = "M:" + typeName + "." + XmlDocUtils.ToEscapedMemberName (member.GetAttribute("MemberName")) + MakeArgs(member);
|
||||
if (member.GetAttribute("MemberName") == "op_Implicit" || member.GetAttribute("MemberName") == "op_Explicit")
|
||||
name += "~" + XmlDocUtils.ToTypeName (member.SelectSingleNode("ReturnValue/ReturnType").InnerText, member);
|
||||
return name;
|
||||
}
|
||||
case "Property":
|
||||
return "P:" + typeName + "." + XmlDocUtils.ToEscapedMemberName (member.GetAttribute("MemberName")) + MakeArgs(member);
|
||||
default:
|
||||
throw new NotSupportedException ("MemberType '" + memberType + "' is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
static string MakeArgs (XmlElement member)
|
||||
{
|
||||
XmlNodeList parameters = member.SelectNodes ("Parameters/Parameter");
|
||||
if (parameters.Count == 0)
|
||||
return "";
|
||||
StringBuilder args = new StringBuilder ();
|
||||
args.Append ("(");
|
||||
args.Append (XmlDocUtils.ToTypeName (parameters [0].Attributes ["Type"].Value, member));
|
||||
for (int i = 1; i < parameters.Count; ++i) {
|
||||
args.Append (",");
|
||||
args.Append (XmlDocUtils.ToTypeName (parameters [i].Attributes ["Type"].Value, member));
|
||||
}
|
||||
args.Append (")");
|
||||
return args.ToString ();
|
||||
}
|
||||
|
||||
private static void AddNamespaceSummary(XmlDocument nsSummaries, string basepath, string currentNs) {
|
||||
foreach (var filename in new [] {
|
||||
Path.Combine(basepath, currentNs + ".xml"),
|
||||
Path.Combine(basepath, "ns-" + currentNs + ".xml")}) {
|
||||
if (File.Exists(filename)) {
|
||||
XmlDocument nsSummary = new XmlDocument();
|
||||
nsSummary.Load(filename);
|
||||
XmlElement ns = nsSummaries.CreateElement("namespace");
|
||||
nsSummaries.DocumentElement.AppendChild(ns);
|
||||
ns.SetAttribute("name", currentNs);
|
||||
ns.InnerText = nsSummary.SelectSingleNode("/Namespace/Docs/summary").InnerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateMember(string name, XmlElement input, XmlElement output) {
|
||||
XmlElement member = output.OwnerDocument.CreateElement("member");
|
||||
output.AppendChild(member);
|
||||
|
||||
member.SetAttribute("name", name);
|
||||
|
||||
foreach (XmlNode docnode in input.SelectSingleNode("Docs"))
|
||||
member.AppendChild(output.OwnerDocument.ImportNode(docnode, true));
|
||||
}
|
||||
|
||||
private static void WriteXml(XmlElement element, System.IO.TextWriter output) {
|
||||
XmlTextWriter writer = new XmlTextWriter(output);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
writer.Indentation = 4;
|
||||
writer.IndentChar = ' ';
|
||||
element.WriteTo(writer);
|
||||
output.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
183
external/api-doc-tools/mdoc/Mono.Documentation/msitomsx.cs
vendored
Normal file
183
external/api-doc-tools/mdoc/Mono.Documentation/msitomsx.cs
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
//
|
||||
// msitomsx.cs: Microsoft Internal XML to Microsoft XML Documentation
|
||||
//
|
||||
// Arguably this doesn't belong in mdoc, but I'd rather not do some
|
||||
// stand-alone tool either, especially since the primary reason it exists is
|
||||
// to facilitate generating ECMA documentation via mdoc-update and
|
||||
// mdoc-update-ecma-xml...
|
||||
//
|
||||
// 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.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Xsl;
|
||||
|
||||
using Mono.Options;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
class MsidocToMsxdocConverter : MDocCommand {
|
||||
|
||||
XslCompiledTransform msiToMsxTransform = new XslCompiledTransform ();
|
||||
|
||||
public MsidocToMsxdocConverter ()
|
||||
{
|
||||
using (var r = XmlReader.Create (
|
||||
Assembly.GetExecutingAssembly ().GetManifestResourceStream ("msitomsx.xsl")))
|
||||
msiToMsxTransform.Load (r);
|
||||
}
|
||||
|
||||
public override void Run (IEnumerable<string> args)
|
||||
{
|
||||
var types = new List<string> ();
|
||||
string outdir = null;
|
||||
|
||||
var options = new OptionSet () {
|
||||
{ "o|out=",
|
||||
"{DIRECTORY} to create Microsoft XML assembly.xml documentation files.",
|
||||
v => outdir = v },
|
||||
{ "library=",
|
||||
"Ignored for compatibility with update-ecma-xml.",
|
||||
v => {} },
|
||||
{ "type=",
|
||||
"The full {TYPE} name of a type to copy into the output file.",
|
||||
v => types.Add (v) },
|
||||
};
|
||||
var sources = Parse (options, args, "export-ecma-xml",
|
||||
"[OPTIONS]+ DIRECTORIES",
|
||||
"Convert Microsoft internal XML documentation within DIRECTORIES into\n" +
|
||||
"Microsoft XML documentation.\n" +
|
||||
"\n" +
|
||||
"Microsoft internal XML documentation is a custom XML dialect (yay) with\n" +
|
||||
"a specific directory structure:\n" +
|
||||
"\n" +
|
||||
"\tROOT/dotted.namespace/asset.xml\n" +
|
||||
"\n" +
|
||||
"where ROOT is a directory that can be passed as one of the DIRECTORIES\n" +
|
||||
"arguments to x-msitomsx, dotted.namespace is the lowercased namespace\n" +
|
||||
"in dotted form, e.g. 'system.threading', and asset.xml is the name of \n" +
|
||||
"the \"asset\" being documented. The asset.xml basename is a GUID, and\n" +
|
||||
"the file contains type/namespace/etc. documentation, one file per asset.\n" +
|
||||
"\n" +
|
||||
"There is no separation of assemblies in this format, only namespaces.\n" +
|
||||
"Types from all assemblies are intermixed with each other.\n" +
|
||||
"\n" +
|
||||
"The output of x-msitomsx will be a set of files in the --out directory,\n" +
|
||||
"one file per assembly (normal 'csc /doc' convention). For example,\n" +
|
||||
"\n" +
|
||||
"\tmdoc x-msitomsx -o docs import-root --type System.String\n" +
|
||||
"\n" +
|
||||
"will create the file 'docs/mscorlib.dll' which will contain the converted\n" +
|
||||
"documentation for the System.String type.");
|
||||
if (sources == null)
|
||||
return;
|
||||
if (sources.Count == 0)
|
||||
Error ("No directories specified.");
|
||||
if (outdir == null)
|
||||
Error ("No output directory specified. Please use --out=DIRECTORY.");
|
||||
|
||||
types.Sort ();
|
||||
|
||||
Dictionary<string, XDocument> docs = Convert (sources, types);
|
||||
foreach (KeyValuePair<string, XDocument> e in docs) {
|
||||
using (var o = CreateWriter (Path.Combine (outdir, e.Key + ".xml")))
|
||||
e.Value.WriteTo (o);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, XDocument> Convert (List<string> sources, List<string> types)
|
||||
{
|
||||
var docs = new Dictionary<string, XDocument> ();
|
||||
|
||||
foreach (var source in sources) {
|
||||
foreach (var dir in Directory.GetDirectories (source)) {
|
||||
foreach (var file in Directory.GetFiles (dir, "*.xml")) {
|
||||
ConvertDocs (docs, types, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return docs;
|
||||
}
|
||||
|
||||
private void ConvertDocs (Dictionary<string, XDocument> docs, List<string> types, string file)
|
||||
{
|
||||
var doc = LoadFile (file);
|
||||
var type = doc.Root.Element ("members").Element ("member").Attribute ("name").Value;
|
||||
|
||||
if (type.StartsWith ("N:"))
|
||||
return;
|
||||
|
||||
if (!type.StartsWith ("T:"))
|
||||
throw new InvalidOperationException ("File '" + file + "' doesn't contain type documentation, it contains docs for: " + type);
|
||||
|
||||
type = type.Substring (2);
|
||||
if (types.Count > 0 && types.BinarySearch (type) < 0)
|
||||
return;
|
||||
|
||||
var assembly = doc.Root.Element ("assembly").Element ("name").Value;
|
||||
XDocument asmdocs;
|
||||
if (!docs.TryGetValue (assembly, out asmdocs)) {
|
||||
docs.Add (assembly,
|
||||
asmdocs = new XDocument (
|
||||
new XElement ("doc",
|
||||
new XElement ("assembly",
|
||||
new XElement ("name", assembly)),
|
||||
new XElement ("members"))));
|
||||
}
|
||||
|
||||
var import = new XDocument ();
|
||||
msiToMsxTransform.Transform (doc.CreateReader (), import.CreateWriter ());
|
||||
|
||||
asmdocs.Root.Element ("members").Add (import.Root.Element ("members").Elements ("member"));
|
||||
}
|
||||
|
||||
static XDocument LoadFile (string file)
|
||||
{
|
||||
using (XmlReader r = XmlReader.Create (file))
|
||||
return XDocument.Load (r);
|
||||
}
|
||||
|
||||
static XmlWriter CreateWriter (string file)
|
||||
{
|
||||
var settings = new XmlWriterSettings {
|
||||
Encoding = new UTF8Encoding (false),
|
||||
Indent = true,
|
||||
IndentChars = " ",
|
||||
NewLineChars = "\r\n",
|
||||
OmitXmlDeclaration = true,
|
||||
};
|
||||
|
||||
return XmlWriter.Create (file, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user