This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 72e55442fa2f5b9a4b84d93f885b21c04cf944ed Author: Shad Storhaug <[email protected]> AuthorDate: Thu Feb 24 11:05:18 2022 +0700 docs: Updated docs.ps1 and plugins to update the Changes link on the docs home page to point to the correct tag in the GitHub repository (fixes #621). --- .../EnvironmentVariableDfmTextInlineRule.cs | 49 +++++++++++ .../EnvironmentVariableInCodeBlockRule.cs | 47 +++++++++++ .../EnvironmentVariableInLinkInlineRule.cs | 98 ++++++++++++++++++++++ .../EnvironmentVariableInlineRule.cs | 51 ++++++----- .../EnvironmentVariableRendererPart.cs | 73 ++++++++-------- .../LuceneDocsPlugins/EnvironmentVariableUtil.cs | 67 +++++++++++++++ .../LuceneDocsPlugins/LuceneDfmEngineCustomizer.cs | 65 +++++++++----- src/docs/LuceneDocsPlugins/LuceneNoteBlockRule.cs | 37 ++++---- src/docs/LuceneDocsPlugins/LuceneNoteBlockToken.cs | 38 ++++----- .../LuceneNoteTokenRendererPart.cs | 38 ++++----- src/docs/LuceneDocsPlugins/RendererPartProvider.cs | 43 +++++----- websites/apidocs/docs.ps1 | 4 + websites/apidocs/index.md | 2 +- 13 files changed, 445 insertions(+), 167 deletions(-) diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableDfmTextInlineRule.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableDfmTextInlineRule.cs new file mode 100644 index 0000000..e68145c --- /dev/null +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableDfmTextInlineRule.cs @@ -0,0 +1,49 @@ +//using Microsoft.DocAsCode.Dfm; +//using Microsoft.DocAsCode.MarkdownLite; +//using System; +//using System.Text; +//using System.Text.RegularExpressions; + +//namespace LuceneDocsPlugins +//{ +// // LUCENENET TODO: This is not functional yet + +// /* +// * Licensed to the Apache Software Foundation (ASF) under one or more +// * contributor license agreements. See the NOTICE file distributed with +// * this work for additional information regarding copyright ownership. +// * The ASF licenses this file to You under the Apache License, Version 2.0 +// * (the "License"); you may not use this file except in compliance with +// * the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ + +// public class EnvironmentVariableDfmTextInlineRule : DfmTextInlineRule +// { +// public static readonly Regex EnvVar = EnvironmentVariableUtil.EnvVarRegexInline; + +// public override IMarkdownToken TryMatch(IMarkdownParser parser, IMarkdownParsingContext context) +// { +// var match = Text.Match(context.CurrentMarkdown); +// if (match.Length == 0) +// { +// return null; +// } +// var sourceInfo = context.Consume(match.Length); + +// //Console.WriteLine("Hey!!!!"); + +// var environmentVariableMatch = EnvVar.Match(match.Groups[0].Value); +// //Console.WriteLine(environmentVariableMatch.Success); +// string replacement = environmentVariableMatch.Success ? EnvironmentVariableUtil.ReplaceEnvironmentVariables(match.Groups[0].Value, match, new StringBuilder(match.Groups[0].Value.Length)) : match.Groups[0].Value; +// return new MarkdownTextToken(this, parser.Context, StringHelper.Escape(Smartypants(parser.Options, replacement)), sourceInfo); +// } +// } +//} diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableInCodeBlockRule.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableInCodeBlockRule.cs new file mode 100644 index 0000000..9d64892 --- /dev/null +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableInCodeBlockRule.cs @@ -0,0 +1,47 @@ +//using Microsoft.DocAsCode.MarkdownLite; +//using System.Text.RegularExpressions; + +//namespace LuceneDocsPlugins +//{ +// // LUCENENET TODO: This is not functional yet + +// /* +// * Licensed to the Apache Software Foundation (ASF) under one or more +// * contributor license agreements. See the NOTICE file distributed with +// * this work for additional information regarding copyright ownership. +// * The ASF licenses this file to You under the Apache License, Version 2.0 +// * (the "License"); you may not use this file except in compliance with +// * the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ + +// public class EnvironmentVariableInCodeBlockRule : MarkdownCodeBlockRule +// { +// public static readonly Regex EnvVarRegex = EnvironmentVariableUtil.EnvVarRegexInline; + +// public override IMarkdownToken TryMatch(IMarkdownParser parser, IMarkdownParsingContext context) +// { +// //Console.WriteLine("Hello World!"); + +// var token = base.TryMatch(parser, context) as MarkdownCodeBlockToken; +// if (token is null) return null; + +// //Console.WriteLine("Alert: Code."); +// //Console.WriteLine(token.Code); + +// var environmentVariableMatch = EnvVarRegex.Match(token.Code); +// if (!environmentVariableMatch.Success) return token; + +// var code = EnvironmentVariableUtil.ReplaceEnvironmentVariables(token.Code, environmentVariableMatch); + +// return new MarkdownCodeBlockToken(token.Rule, token.Context, code, token.Lang, token.SourceInfo); +// } +// } +//} diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableInLinkInlineRule.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableInLinkInlineRule.cs new file mode 100644 index 0000000..73f3ca8 --- /dev/null +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableInLinkInlineRule.cs @@ -0,0 +1,98 @@ +using Microsoft.DocAsCode.MarkdownLite; +using System; +using System.Text; +using System.Text.RegularExpressions; + +namespace LuceneDocsPlugins +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /// <summary> + /// Replaces an environment variables that are nested within the text, href, or title of a Markdown link. + /// </summary> + public class EnvironmentVariableInLinkInlineRule : MarkdownLinkInlineRule + { + public override string Name => "EnvVar.Link"; + + public static readonly Regex EnvVarRegex = EnvironmentVariableUtil.EnvVarRegexInline; + + public override IMarkdownToken TryMatch(IMarkdownParser parser, IMarkdownParsingContext context) + { + // NOTE: This copies the logic from MarkdownLinkInlineRule, but does not match if there are no links to replace. + // This isn't perfect, but at least it ensures we only match the one [Changes]() link it is intended to match + // and replaces multiple environment variables if they exist. + + // The when the Consume() method below is called, there doesn't appear to be any way to make the cursor backtrack, + // and the scan is only performed once. This is why we have to resort to this. Not sure if there is a better way to make + // nested tokens than this, but it doesn't seem like there is. + + var match = Link.Match(context.CurrentMarkdown); + if (match.Length == 0) + { + return null; + } + if (MarkdownInlineContext.GetIsInLink(parser.Context) && match.Value[0] != '!') + { + return null; + } + if (IsEscape(match.Groups[1].Value) || IsEscape(match.Groups[2].Value)) + { + return null; + } + + var text = match.Groups[1].Value; + var title = match.Groups[4].Value; + var href = match.Groups[2].Value; + + var textMatch = EnvVarRegex.Match(text); + var titleMatch = EnvVarRegex.Match(title); + var hrefMatch = EnvVarRegex.Match(href); + + // Don't match unless we have a match for our EnvVar pattern in any part of the link + if (!textMatch.Success && !titleMatch.Success && !hrefMatch.Success) + return null; + + StringBuilder scratch = null; + + if (textMatch.Success || titleMatch.Success || hrefMatch.Success) + scratch = new StringBuilder(); + + if (textMatch.Success) + text = EnvironmentVariableUtil.ReplaceEnvironmentVariables(text, textMatch, scratch); + if (titleMatch.Success) + title = EnvironmentVariableUtil.ReplaceEnvironmentVariables(title, titleMatch, scratch); + if (hrefMatch.Success) + href = EnvironmentVariableUtil.ReplaceEnvironmentVariables(href, hrefMatch, scratch); + + var sourceInfo = context.Consume(match.Length); + return GenerateToken(parser, href, title, text, match.Value[0] == '!', sourceInfo, MarkdownLinkType.NormalLink, null); + } + + private bool IsEscape(string text) + { + for (int i = text.Length - 1; i >= 0; i--) + { + if (text[i] != '\\') + { + return (text.Length - i) % 2 == 0; + } + } + return text.Length % 2 == 1; + } + } +} diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableInlineRule.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableInlineRule.cs index 7fc8b34..545b83b 100644 --- a/src/docs/LuceneDocsPlugins/EnvironmentVariableInlineRule.cs +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableInlineRule.cs @@ -1,37 +1,30 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - +using Microsoft.DocAsCode.MarkdownLite; using System; -using System.Collections.Immutable; -using System.Text.RegularExpressions; -using Microsoft.DocAsCode.MarkdownLite; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class EnvironmentVariableInlineRule : IMarkdownRule { // give it a name public string Name => "EnvVarToken"; - // define my regex to match - private static readonly Regex _envVarRegex = new Regex(@"^\<EnvVar:(\w+?)\>", RegexOptions.Compiled); - // process the match public IMarkdownToken TryMatch(IMarkdownParser parser, IMarkdownParsingContext context) { @@ -41,8 +34,12 @@ namespace LuceneDocsPlugins // dotnet tool install lucene-cli -g --version [EnvVar: LuceneNetVersion] // ``` - var match = _envVarRegex.Match(context.CurrentMarkdown); - if (match.Length == 0) return null; + //Console.Write(context.CurrentMarkdown); + //Console.WriteLine("------------------------------------------------------------------------------"); + + var match = EnvironmentVariableUtil.EnvVarRegex.Match(context.CurrentMarkdown); + + if (!match.Success) return null; var envVar = match.Groups[1].Value; var text = Environment.GetEnvironmentVariable(envVar); diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableRendererPart.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableRendererPart.cs index f6d5cfa..9fa48b6 100644 --- a/src/docs/LuceneDocsPlugins/EnvironmentVariableRendererPart.cs +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableRendererPart.cs @@ -1,43 +1,40 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ +//using Microsoft.DocAsCode.Dfm; +//using Microsoft.DocAsCode.MarkdownLite; -using Microsoft.DocAsCode.Dfm; -using Microsoft.DocAsCode.MarkdownLite; -using System.Linq; +//namespace LuceneDocsPlugins +//{ +// /* +// * Licensed to the Apache Software Foundation (ASF) under one or more +// * contributor license agreements. See the NOTICE file distributed with +// * this work for additional information regarding copyright ownership. +// * The ASF licenses this file to You under the Apache License, Version 2.0 +// * (the "License"); you may not use this file except in compliance with +// * the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ -namespace LuceneDocsPlugins -{ - // TODO: this is actually not needed since we are inserting our own inline rule, although the docs - // claim we need it https://dotnet.github.io/docfx/tutorial/howto_customize_docfx_flavored_markdown.html - // maybe that is only the case for block level items? I cannot quite figure it out looking at the docfx code +// // TODO: this is actually not needed since we are inserting our own inline rule, although the docs +// // claim we need it https://dotnet.github.io/docfx/tutorial/howto_customize_docfx_flavored_markdown.html +// // maybe that is only the case for block level items? I cannot quite figure it out looking at the docfx code - ///// <summary> - ///// Used to replace environment variables tokens with their values - ///// </summary> - //public sealed class EnvironmentVariableRendererPart : DfmCustomizedRendererPartBase<IMarkdownRenderer, MarkdownTextToken, MarkdownInlineContext> - //{ - // public override string Name => "EnvironmentVariableRendererPart"; +// /// <summary> +// /// Used to replace environment variables tokens with their values +// /// </summary> +// public sealed class EnvironmentVariableRendererPart : DfmCustomizedRendererPartBase<IMarkdownRenderer, MarkdownTextToken, MarkdownInlineContext> +// { +// public override string Name => "EnvironmentVariableRendererPart"; - // public override bool Match(IMarkdownRenderer renderer, MarkdownTextToken token, MarkdownInlineContext context) - // => true; +// public override bool Match(IMarkdownRenderer renderer, MarkdownTextToken token, MarkdownInlineContext context) +// => true; - // public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownTextToken token, MarkdownInlineContext context) - // => token.Content; - //} -} \ No newline at end of file +// public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownTextToken token, MarkdownInlineContext context) +// => token.Content; +// } +//} \ No newline at end of file diff --git a/src/docs/LuceneDocsPlugins/EnvironmentVariableUtil.cs b/src/docs/LuceneDocsPlugins/EnvironmentVariableUtil.cs new file mode 100644 index 0000000..9bdd241 --- /dev/null +++ b/src/docs/LuceneDocsPlugins/EnvironmentVariableUtil.cs @@ -0,0 +1,67 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; + +namespace LuceneDocsPlugins +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class EnvironmentVariableUtil + { + public const string EnvVarRegexString = @"[\<\[]EnvVar\:(\w+?)[\>\]]"; + public static readonly Regex EnvVarRegex = new Regex("^" + EnvVarRegexString, RegexOptions.Compiled); + public static readonly Regex EnvVarRegexInline = new Regex(EnvVarRegexString, RegexOptions.Compiled | RegexOptions.Multiline); + + + public static string ReplaceEnvironmentVariables(string sourceText, Match match) + => ReplaceEnvironmentVariables(sourceText, match, reuse: null); + + public static string ReplaceEnvironmentVariables(string sourceText, Match match, StringBuilder reuse) + { + if (match.Success) + { + if (reuse is null) + reuse = new StringBuilder(); + else + reuse.Clear(); + + int lastMatchEnd = 0; + + do + { + var envVar = match.Groups[1].Value; + + // Append the prefix that didn't match the regex (or text since last match) + reuse.Append(sourceText.Substring(lastMatchEnd, match.Index - lastMatchEnd)); + + // Do the replacement of the regex match + reuse.Append(Environment.GetEnvironmentVariable(envVar)); + + lastMatchEnd = match.Index + match.Length; + + } while ((match = match.NextMatch()).Success); + + // Append the suffix that didn't match the regex + reuse.Append(sourceText.Substring(lastMatchEnd)); + + return reuse.ToString(); + } + return sourceText; + } + } +} diff --git a/src/docs/LuceneDocsPlugins/LuceneDfmEngineCustomizer.cs b/src/docs/LuceneDocsPlugins/LuceneDfmEngineCustomizer.cs index 6bfd711..08865b5 100644 --- a/src/docs/LuceneDocsPlugins/LuceneDfmEngineCustomizer.cs +++ b/src/docs/LuceneDocsPlugins/LuceneDfmEngineCustomizer.cs @@ -1,29 +1,29 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - +using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Composition; using Microsoft.DocAsCode.Dfm; using Microsoft.DocAsCode.MarkdownLite; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// <summary> /// Exports our custom markdown parser via MEF to DocFx /// </summary> @@ -31,14 +31,39 @@ namespace LuceneDocsPlugins public class LuceneDfmEngineCustomizer : IDfmEngineCustomizer { public void Customize(DfmEngineBuilder builder, IReadOnlyDictionary<string, object> parameters) - { + { // insert inline rule at the top + builder.InlineRules = builder.InlineRules.Insert(0, new EnvironmentVariableInLinkInlineRule()); builder.InlineRules = builder.InlineRules.Insert(0, new EnvironmentVariableInlineRule()); + // LUCENENET TODO: The inline text replacement still isn't working. Not sure why. + //builder.InlineRules = builder.InlineRules.Insert(0, new EnvironmentVariableDfmTextInlineRule()); + + //// Find the MarkdownLinkInlineRule position, and insert rules to replace text within the link before it + //var markdownLinkInlineRuleIndex = builder.InlineRules.FindIndex(r => r is MarkdownLinkInlineRule); + //builder.InlineRules.Insert(markdownLinkInlineRuleIndex, new EnvironmentVariableInLinkInlineRule()); + + //builder.InlineRules = Replace<DfmTextInlineRule, EnvironmentVariableDfmTextInlineRule>(builder.InlineRules); // insert block rule above header rule. Why? I dunno, that's what the docs say: // https://dotnet.github.io/docfx/tutorial/intro_markdown_lite.html#select-token-kind var blockIndex = builder.BlockRules.FindIndex(r => r is MarkdownHeadingBlockRule); builder.BlockRules = builder.BlockRules.Insert(blockIndex, new LuceneNoteBlockRule()); + + // LUCENENET TODO: The code replacement still isn't working (or even matching). Not sure why. + //builder.BlockRules = Replace<MarkdownCodeBlockRule, EnvironmentVariableInCodeBlockRule>(builder.BlockRules); + } + + private static ImmutableList<IMarkdownRule> Replace<TSource, TReplacement>(ImmutableList<IMarkdownRule> blockRules) + where TSource : IMarkdownRule + where TReplacement : IMarkdownRule, new() + { + var index = blockRules.FindIndex(item => item is TSource); + if (index < 0) + { + throw new ArgumentException($"{typeof(TSource).Name} should exist!"); + } + blockRules = blockRules.Insert(index, new TReplacement()); + return blockRules.RemoveAt(index + 1); } } } diff --git a/src/docs/LuceneDocsPlugins/LuceneNoteBlockRule.cs b/src/docs/LuceneDocsPlugins/LuceneNoteBlockRule.cs index af3ce3c..938ef3f 100644 --- a/src/docs/LuceneDocsPlugins/LuceneNoteBlockRule.cs +++ b/src/docs/LuceneDocsPlugins/LuceneNoteBlockRule.cs @@ -1,27 +1,24 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using Microsoft.DocAsCode.MarkdownLite; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /// <summary> /// The regex rule to parse out the custom Lucene tokens diff --git a/src/docs/LuceneDocsPlugins/LuceneNoteBlockToken.cs b/src/docs/LuceneDocsPlugins/LuceneNoteBlockToken.cs index f98041e..d8dd4f6 100644 --- a/src/docs/LuceneDocsPlugins/LuceneNoteBlockToken.cs +++ b/src/docs/LuceneDocsPlugins/LuceneNoteBlockToken.cs @@ -1,26 +1,24 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using Microsoft.DocAsCode.MarkdownLite; +using Microsoft.DocAsCode.MarkdownLite; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// <summary> /// A custom token class representing our custom Lucene tokens /// </summary> diff --git a/src/docs/LuceneDocsPlugins/LuceneNoteTokenRendererPart.cs b/src/docs/LuceneDocsPlugins/LuceneNoteTokenRendererPart.cs index 8314577..8782ae1 100644 --- a/src/docs/LuceneDocsPlugins/LuceneNoteTokenRendererPart.cs +++ b/src/docs/LuceneDocsPlugins/LuceneNoteTokenRendererPart.cs @@ -1,28 +1,26 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using Microsoft.DocAsCode.Dfm; +using Microsoft.DocAsCode.Dfm; using Microsoft.DocAsCode.MarkdownLite; using System.Text; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// <summary> /// Used to replace custom Lucene tokens with custom HTML markup /// </summary> diff --git a/src/docs/LuceneDocsPlugins/RendererPartProvider.cs b/src/docs/LuceneDocsPlugins/RendererPartProvider.cs index 20c17a3..58ddda3 100644 --- a/src/docs/LuceneDocsPlugins/RendererPartProvider.cs +++ b/src/docs/LuceneDocsPlugins/RendererPartProvider.cs @@ -1,38 +1,39 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Composition; using Microsoft.DocAsCode.Dfm; namespace LuceneDocsPlugins { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// <summary> /// Exports our custom renderer via MEF to DocFx /// </summary> [Export(typeof(IDfmCustomizedRendererPartProvider))] public class RendererPartProvider : IDfmCustomizedRendererPartProvider { + private readonly LuceneNoteTokenRendererPart luceneNoteTokenRendererPart = new LuceneNoteTokenRendererPart(); + public IEnumerable<IDfmCustomizedRendererPart> CreateParts(IReadOnlyDictionary<string, object> parameters) { - yield return new LuceneNoteTokenRendererPart(); + yield return luceneNoteTokenRendererPart; //yield return new EnvironmentVariableRendererPart(); + //yield return new EnvironmentVariableBlockRendererPart(); } } diff --git a/websites/apidocs/docs.ps1 b/websites/apidocs/docs.ps1 index b344281..09044fa 100644 --- a/websites/apidocs/docs.ps1 +++ b/websites/apidocs/docs.ps1 @@ -45,8 +45,12 @@ if ($BaseUrl -eq 'https://lucenenet.apache.org/docs/') { $BaseUrl = $BaseUrl.TrimEnd('/') # Remove any trailing slash Write-Host "Base URL for xref map set to $BaseUrl" +# Generate the Git tag for the current version +$VCSLabel = 'Lucene.Net_' + $LuceneNetVersion.Replace('.', '_').Replace('-', '_') + # set env vars that will be replaced in Markdown $env:LuceneNetVersion = $LuceneNetVersion +$env:LuceneNetReleaseTag = $VCSLabel [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 diff --git a/websites/apidocs/index.md b/websites/apidocs/index.md index 1a198e5..d0ebe9e 100644 --- a/websites/apidocs/index.md +++ b/websites/apidocs/index.md @@ -29,7 +29,7 @@ on some of the conceptual or inner details of Lucene: ## Reference Documents -- [Changes](https://github.com/apache/lucenenet/releases/tag/<EnvVar:LuceneNetReleaseTag>): List of changes in this release. +- [Changes](https://github.com/apache/lucenenet/releases/tag/[EnvVar:LuceneNetReleaseTag]): List of changes in this release. <!-- - System Requirements: Minimum and supported .NET versions. LUCENENT TODO: Add link --> - [Migration Guide](xref:Lucene.Net.Migration.Guide): What changed in Lucene 4; how to migrate code from Lucene 3.x. - [Source Stepping](xref:source-stepping): How to use the Visual Studio debugger to step into Lucene.NET source code.
