Without curtailing her trademark potty-mouth humor and shock tactics, comedian Sarah Silverman has written a memoir that’s sweet, funny, real and, dare I say it, occasionally even touching.

Laced as it is with swear words, including That Word You Never Want Your Mother to Hear You Say, “The Bedwetter” is going to present parents and librarians with a dilemma about its appropriateness for the under-18 set.

The book’s first chunk is a wonderful story of growing up loved, troubled and Jewish in small-town New Hampshire in the ’70s and early ’80s. Both parents loved her, but they got divorced. Her brother Jeffrey died in a crib accident before she was born. She was depressed as a youth; at one point, the doctor treating her had her on 16 Xanax a day.

Before that makes you weepy, consider that Silverman mocks her youthful woes and angst as ruthlessly as she mocks anyone. Her heading for the Xanax segment: “An Emotionally Disturbed Teenager Is Given a Bottomless Well of Insanely Addictive Drugs as a Means to Improve Her Life, and Other Outstanding Achievements for the New Hampshire Mental Health Community.”

In between jokes, she has kind words for her stepfather, “the one parent who didn’t try to fix me.” During a spell when she had stopped going to high school classes because her depression and fear were too overpowering, he held her while she sobbed and then asked only: “What does it feel like?” She thought about it and replied, “I feel homesick.”

Best of all, Silverman touches all the milestones and wet spots of the titular affliction, medically known as enuresis: parents who get up at night with the bedwetting child, fear of embarrassment on a sleepover, the electric pad in the bed that jolts the child awake with its alarm, the prescient doctor who declares early on that she’ll outgrow it (and she does). Her path to dry sheets and sanity is complicated along the way by a therapist who decided to hang himself while she was in his waiting room.

In later sections of the book, Silverman describes her late discovery of and furious engagement in sex, her struggle to make it as a performer and the taste battles both she and her Comedy Central show, “The Sarah Silverman Program,” seem to court. Sometimes her shtick, as she explains it, resembles songwriter Randy Newman’s: She mocks a prejudiced personality or attitude so well from the inside that angry people assume she is, for example, anti-Asian.

Readers’ views of the later chapters might depend on their tolerance for flatulence jokes, sexual references and backstage tales. Nonetheless, Silverman’s book suggests that, behind the cute face and dirty mouth, there’s a clever woman with a warm heart.