// extracts the line's param string private string ExtractLineParam(string line, out string[] paramSettings, out string[] paramData) { paramSettings = null; paramData = new string[0]; string param = line.TrimStart(lang.GetSingleCommentChar()).TrimStart(); if (!param.StartsWith("@")) { return(null); } string[] paramDataArr = param.Split(' ')[0].Split('['); // e.g. split the default param data from "-- @return[default=false] type text with [ etc." or "-- @note text with h[ .." too string extractedParam = paramDataArr[0].TrimStart('@').ToLower(); int lastPos = param.IndexOf(' '); if (paramDataArr.Length > 1) // there are settings { paramSettings = NeoDoc.GetEntriesFromString(param, out lastPos).ToArray(); // get entries of the first list based on the first layer } // paramData string[] tmpParamData = param.Substring(lastPos + 1).TrimStart('@').TrimStart().Split(' '); // clean the param data paramData = new string[tmpParamData.Length]; for (int i = 0; i < paramData.Length; i++) { paramData[i] = tmpParamData[i].Trim(); } return(extractedParam.Trim()); }
public void Process() { paramsList = new List <Param>(); for (CurrentLineCount = 0; CurrentLineCount < Lines.Length; CurrentLineCount++) { string line = Lines[CurrentLineCount]; if (string.IsNullOrEmpty(line)) // ignore empty lines { continue; } if (!paramMatcher.IsLineComment(line)) // if there is no comment but something else. That means the doc comment section has end { langMatcher.GetDataStructureType(lang, line)?.Initialize(this); // cleans the params list to be used for the next function or whatever, even if there is no dataStructure match paramsList.Clear(); continue; } Param lineParam = paramMatcher.GetLineParam(line); if (lineParam == null) // if there is no line param { string foundLineParamString = paramMatcher.GetLineParamString(line); if (!string.IsNullOrEmpty(foundLineParamString)) // if there is a not registered param { NeoDoc.WriteErrors("Unregistered param detected", new List <string>() { "'" + foundLineParamString + "' ('" + line + "')" }, relPath, CurrentLineCount + 1, (int)NeoDoc.ERROR_CODES.UNREGISTERED_PARAM); } else { if (paramMatcher.IsLineCommentStart(line)) // if matching e.g. "---" { paramsList.Clear(); // clear the paramsList if a new docu block starts lineParam = new DescParam(); // start with a new description by default. HINT: That means that if using e.g. `---` instead of `--` while documenting e.g. a param addition in a new line, this line will be handled as a new description entry instead of a continued param addition / param description. paramsList.Add(lineParam); } else if (paramsList.Count > 0) // if there are params in the list { lineParam = paramsList.ElementAt(paramsList.Count - 1); // use last param as new line param to support multiline commenting style e.g. } lineParam?.ProcessAddition(paramMatcher.GetLineCommentData(line)); // add additional content } } else { lineParam.ModifyFileParser(this); // e.g. function or wrapper params will clean params list if it already contains a wrapper / ... } } paramsList = null; }