-
Notifications
You must be signed in to change notification settings - Fork 872
/
Copy pathRtfDocumentProcessor.cs
74 lines (65 loc) · 2.28 KB
/
RtfDocumentProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace RtfDocumentProcessors
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.IO;
using Docfx.Common;
using Docfx.Plugins;
[Export(typeof(IDocumentProcessor))]
public class RtfDocumentProcessor : IDocumentProcessor
{
#region BuildSteps
[ImportMany(nameof(RtfDocumentProcessor))]
public IEnumerable<IDocumentBuildStep> BuildSteps { get; set; }
#endregion
#region Name
public string Name => nameof(RtfDocumentProcessor);
#endregion
#region GetProcessingPriority
public ProcessingPriority GetProcessingPriority(FileAndType file)
{
if (file.Type == DocumentType.Article &&
".rtf".Equals(Path.GetExtension(file.File), StringComparison.OrdinalIgnoreCase))
{
return ProcessingPriority.Normal;
}
return ProcessingPriority.NotSupported;
}
#endregion
#region Load
public FileModel Load(FileAndType file, ImmutableDictionary<string, object> metadata)
{
var content = new Dictionary<string, object>
{
["conceptual"] = File.ReadAllText(Path.Combine(file.BaseDir, file.File)),
["type"] = "Conceptual",
["path"] = file.File,
};
var localPathFromRoot = PathUtility.MakeRelativePath(EnvironmentContext.BaseDirectory, EnvironmentContext.FileAbstractLayer.GetPhysicalPath(file.File));
return new FileModel(file, content)
{
LocalPathFromRoot = localPathFromRoot,
};
}
#endregion
#region Save
public SaveResult Save(FileModel model)
{
return new SaveResult
{
DocumentType = "Conceptual",
FileWithoutExtension = Path.ChangeExtension(model.File, null),
};
}
#endregion
#region UpdateHref
public void UpdateHref(FileModel model, IDocumentBuildContext context)
{
}
#endregion
}
}