Ticket #1: ddoc.diff

File ddoc.diff, 4.5 kB (added by Mike Wey, 1 year ago)

wraper DDoc patch.

  • gtkD/wrap/utils/GtkDClass.d

    old new  
    6262    private import std.ctype; 
    6363    private import std.path; 
    6464    private import std.stdio; 
     65    private import std.string; 
    6566 
    6667    //Moved up... for dsss: 
    6768    //private import utils.HtmlStrip; 
     
    323324        } 
    324325        gtkDText ~= "\n"; 
    325326 
    326  
    327         if ( wrapper.includeComments() ) 
    328         { 
    329             append(gtkDText, description, tabs); 
    330         } 
     327        //moved to openClass 
     328        //for ddoc the comments need to be right above the class. 
     329        //if ( wrapper.includeComments() ) 
     330        //{ 
     331        //  append(gtkDText, description, tabs); 
     332        //} 
    331333 
    332334        // reset the parent name 
    333335        parentName = null; 
     
    503505                && gtkDParentNamePrefix.length > 0 
    504506                ) 
    505507            { 
    506                 text ~= "private import "~gtkDParentNamePrefix~"."~gtkDParentName~";\n"; 
     508                text ~= "private import "~gtkDParentNamePrefix~"."~gtkDParentName~";"; 
     509            } 
     510 
     511            if ( wrapper.includeComments() ) 
     512            { 
     513                foreach(char[] line; description) 
     514                    text ~= line; 
    507515            } 
     516 
    508517            text ~= getClassHeader(convParms, gtkDParentName) 
    509518                    ~ getImplements(convParms, gtkDParentName); 
    510519//          char[] implements = getImplements(convParms, gtkDParentName); 
     
    19871996                    // comment 
    19881997                    void addComments() 
    19891998                    { 
     1999                        bool stilInParam(char[] comments) 
     2000                        { 
     2001                            return !(find(comments, ":")  == comments.length-1 || 
     2002                                     find(comments, "Returns:") == 0 || 
     2003                                     find(comments, "Since 2.") == 0 || 
     2004                                     find(comments, "See Also") == 0 || 
     2005                                     find(comments, "Property Details") == 0); 
     2006                        } 
     2007 
     2008                        char[][] phraseParams(char[][] comments) 
     2009                        { 
     2010                            char[][] description; 
     2011                            char[][] params; 
     2012                            char[] ret;                          
     2013                             
     2014                            for(int i; i < comments.length; i++) 
     2015                            { 
     2016                                if(find(comments[i], ":") == comments[i].length-1 && find(comments[i], "Returns:") == -1) 
     2017                                { 
     2018                                    //Get the GtkD name of the param 
     2019                                    char[] param = idsToGtkD(comments[i][0 .. $-1], convParms, wrapper.getAliases()); 
     2020 
     2021                                    //If this param is not in the Gtkd Function Skip it. 
     2022                                    if(find(fun.declaration(convParms,wrapper.getAliases()), param) == -1) 
     2023                                    { 
     2024                                        //Loop for multi line descriptons for this param. 
     2025                                        while(i+1 < comments.length && stilInParam(comments[i+1])) 
     2026                                            i++; 
     2027                                        continue; 
     2028                                    } 
     2029 
     2030                                    if(params.length == 0) 
     2031                                        params ~= "Params:"; 
     2032 
     2033                                    //Loop for multi line descriptons for this param. 
     2034                                    bool firstRun = true; 
     2035                                    while(i+1 < comments.length && stilInParam(comments[i+1])) 
     2036                                    { 
     2037                                        i++; 
     2038                                        if(firstRun) 
     2039                                        { 
     2040                                            params ~= param ~" = "~ comments[i]; 
     2041                                            firstRun = false; 
     2042                                        } 
     2043                                        else 
     2044                                            params ~= comments[i]; 
     2045                                    } 
     2046                                } 
     2047                                else if(find(comments[i], "Returns:") > -1) 
     2048                                { 
     2049                                    //Skip return for Constructors. 
     2050                                    if(find(fun.declaration(convParms,wrapper.getAliases()), "this (") > -1) 
     2051                                    { 
     2052                                        //Loop for multi line descriptons for this return. 
     2053                                        while(i+1 < comments.length && stilInParam(comments[i+1])) 
     2054                                            i++; 
     2055                                        continue; 
     2056                                    } 
     2057 
     2058                                    ret ~= comments[i]; 
     2059 
     2060                                    //Loop for multi line descriptons for this return. 
     2061                                    bool firstRun = true; 
     2062                                    while(i+1 < comments.length && stilInParam(comments[i+1])) 
     2063                                    { 
     2064                                        i++; 
     2065                                        ret ~= comments[i]; 
     2066                                    } 
     2067                                } 
     2068                                else if(find(comments[i], "See Also") == 0 || find(comments[i], "Property Details") == 0) 
     2069                                { 
     2070                                    //These sections get included with the last function. 
     2071                                    break; 
     2072                                } 
     2073                                else 
     2074                                { 
     2075                                    //Add the rest to the description. 
     2076                                    description ~= comments[i]; 
     2077                                } 
     2078                            } 
     2079 
     2080                            if(params.length > 0) 
     2081                            { 
     2082                                foreach(char[] line; params) 
     2083                                    description ~= line; 
     2084                            } 
     2085 
     2086                            if(ret.length > 0) 
     2087                                description ~= ret; 
     2088 
     2089                            return description; 
     2090                        } 
     2091 
    19902092                        if ( wrapper.includeComments() ) 
    19912093                        { 
    1992                             member ~= "/**"
     2094                            char[][] comments
    19932095                            while ( line<lines.length ) 
    19942096                            { 
    19952097                                //if ( !tooSoon ) 
    19962098                                //{ 
    19972099                                //  tooSoon = lines[line]=="Since 2.10"; 
    19982100                                //} 
    1999                                 member ~= " * "~lines[line++]; 
     2101                                comments ~= lines[line++]; 
    20002102                            } 
     2103 
     2104                            member ~= "/**"; 
     2105 
     2106                            comments = phraseParams(comments); 
     2107                            foreach(char[] line; comments) 
     2108                                member ~= " * "~ line; 
     2109 
    20012110                            member ~= " */"; 
    20022111                        } 
    20032112                    }