This sentence was written by Goold Brown in his The Grammar of English Grammars, published in 1851. The full text of the book can be found here.
I tried wading through the more relevant sections.
In his observation 17 on rule 4 of his chapter 2, "Articles" (yes, that is how the book is structured), Mr. Brown, among many other things, states that
Because, without this mongrel character, the participle in our language has a
multiplicity of uses unparalleled in any other; and because it seldom
happens that the idea intended by this double construction may not be
otherwise expressed more elegantly.
However, his love of participles was not without its limits for he took care to explain, in his observation 3 on rule 20 of the same chapter, that the participle can indeed be overused:
One may run to great excess in the adoption of such derivatives [the participles], without becoming absolutely unintelligible, and without violating any rule of our common grammars. For example, I may say of somebody, "This very superficial grammatist, supposing empty criticism about the adoption of proper phraseology to be a show of extraordinary erudition, was displaying, in spite of ridicule, a very boastful turgid argument concerning the correction of false syntax, and about the detection of false logic in debate." Now, in what other language than ours, can a string of words anything like the following, come so near to a fair and literal translation of this long sentence? "This exceeding trifling witling, considering ranting criticising concerning adopting fitting wording being exhibiting transcending learning, was displaying, notwithstanding ridiculing, surpassing boasting swelling reasoning, respecting correcting erring writing, and touching detecting deceiving arguing during debating." Here are not all the uses to which our writers apply the participle in ing, but there would seem to be enough, without adding others that are less proper.
So, the sentence was cooked up by a 19th century grammarian to make the point that use of the present participle can lead to confusing sentences. It is therefore probably grammatical, at the very least according to the 19th century grammar espoused by Mr. Brown.