Exemplo n.º 1
0
        private void TerminateChunk(StringBuilder accumulator, MemFileState futureState, bool convertExample, bool noCheck)
        {
            string consumeAndTrim = accumulator.ConsumeAndTrimEndAndNewlines();

            if (consumeAndTrim.Length > 0)
            {
                switch (_currentState)
                {
                case MemFileState.Signatures:
                {
                    var sigs = consumeAndTrim.SplitLines();
                    foreach (var sig in sigs)
                    {
                        SignatureList.Add(sig);
                    }
                    break;
                }

                case MemFileState.Example:
                {
                    var oneExample = new ExampleBlock(consumeAndTrim)
                    {
                        IsNoCheck        = noCheck,
                        IsConvertExample = convertExample
                    };
                    TextBlocks.Add(oneExample);
                    break;
                }

                case MemFileState.Description:
                {
                    if (!_isSummaryFound)
                    {
                        var lines = consumeAndTrim.SplitLines();
                        Summary         = lines[0];
                        consumeAndTrim  = consumeAndTrim.Replace(Summary, "");
                        consumeAndTrim  = consumeAndTrim.TrimEndAndNewlines();
                        _isSummaryFound = true;
                        if (consumeAndTrim.Length == 0)
                        {
                            break;
                        }
                    }
                    var oneText = new DescriptionBlock(consumeAndTrim);
                    TextBlocks.Add(oneText);
                    break;
                }

                case MemFileState.Param:
                {
                    consumeAndTrim = consumeAndTrim.Replace("@param ", "");
                    int              index    = consumeAndTrim.IndexOfAny(new char[] { ' ', '\t' });
                    string           name     = consumeAndTrim.Substring(0, index).Trim();
                    string           doc      = consumeAndTrim.Substring(index + 1).Trim();
                    ParameterWithDoc paramDoc = GetOrCreateParameter(name);
                    paramDoc.Doc = doc;
                    break;
                }

                case MemFileState.Return:
                {
                    consumeAndTrim = consumeAndTrim.Replace("@returns ", "");
                    consumeAndTrim = consumeAndTrim.Replace("@return ", "");

                    GetOrCreateReturnDoc().Doc = consumeAndTrim;
                    break;
                }
                }
            }
            _currentState = futureState;
        }
        private void TerminateChunk(StringBuilder accumulator, MemFileState futureState, bool convertExample = false, bool noCheck = false)
        {
            string consumeAndTrim = accumulator.ConsumeAndTrimEndAndNewlines();
            if (consumeAndTrim.Length > 0)
            {
                switch (_currentState)
                {
                    case MemFileState.Signatures:
                        {
                            var sigs = consumeAndTrim.SplitLines();
                            foreach (var sig in sigs)
                                SignatureList.Add(sig);
                            break;
                        }
                    case MemFileState.Example:
                        {
                            var oneExample = new ExampleBlock(consumeAndTrim)
                                                 {
                                                     IsNoCheck = noCheck,
                                                     IsConvertExample = convertExample
                                                 };
                            TextBlocks.Add(oneExample);
                            break;
                        }

                    case MemFileState.Description:
                        {
                            if (!_isSummaryFound)
                            {
                                var lines = consumeAndTrim.SplitLines();
                                Summary = lines[0];
                                consumeAndTrim = consumeAndTrim.Replace(Summary, "");
                                consumeAndTrim = consumeAndTrim.TrimEndAndNewlines();
                                _isSummaryFound = true;
                                if (consumeAndTrim.Length == 0)
                                    break;
                            }
                            var oneText = new DescriptionBlock(consumeAndTrim);
                            TextBlocks.Add(oneText);
                            break;
                        }
                    case MemFileState.Param:
                        {
                            consumeAndTrim = consumeAndTrim.Replace("@param ", "");
                            int index = consumeAndTrim.IndexOfAny(new char[] {' ', '\t'});
                            string name = consumeAndTrim.Substring(0, index).Trim ();
                            string doc = consumeAndTrim.Substring(index + 1).Trim ();
                            ParameterWithDoc paramDoc = GetOrCreateParameter (name);
                            paramDoc.Doc = doc;
                            break;
                        }
                    case MemFileState.Return:
                        {
                            consumeAndTrim = consumeAndTrim.Replace("@returns ", "");
                            consumeAndTrim = consumeAndTrim.Replace("@return ", "");

                            GetOrCreateReturnDoc ().Doc = consumeAndTrim;
                            break;
                        }
                }
            }
            _currentState = futureState;
        }