SAN FRANCISCO — I could buy my family a tiny square of chocolate. Or a chocolate bar. But instead, I give them the whole chocolate factory.

In what has to be the most accurate use of the term “tasteful renovation,” the former Ghirardelli Chocolate Factory in San Francisco has become one of the best places to stay in the City by the Bay. As the Fairmont Heritage Place, it has become my favorite place to stay when I travel with the whole family.

The red brick castle west of Fisherman’s Wharf with the huge sign spelling out GHIRARDELLI (pronounced GEAR-ar-DELL-ee) has been around since I was a kid, more than a half century ago. It opened as a chocolate factory in 1893, though nearly all its operations have moved since the mid-1960s to more modern facilities across the bay in San Leandro, just south of Oakland.

But the creamy, dark, sweet spirit of the chocolate company remains in the northwest end of Fisherman’s Wharf.

There’s a little corner of the complex, underneath the Beaux Arts bell tower, where small batches of chocolate are still mixed and churned — something to kill the time while you wait for your hot fudge sundae. The light brown, gooey liquid that flows through a vat seems to scream out to have someone stick a hand in and lift out a dripping heap of sweet candy.

It might be for show, but the smells and sounds give a small window into what it must have been like to work here in the early decades of the past century — back when Domingo Ghirardelli, an Italian immigrant who learned the chocolate trade in South America, was churning out chocolate even during earthquakes, fires, wars and economic hard times.

There are few San Franciscans who can remember back to when Ghirardelli Square was anything but a tourist attraction. The buildings were an early success story in historic preservation when they reopened as a shopping arcade and restaurant spot in 1964. The buildings have been listed on the National Historic Register since 1982.

But the whole experience took a sweet leap in 2008 when the dormant upper floors were converted into luxurious apartments operated under another famous San Francisco name, Fairmont, which has the legendary hotel atop Nob Hill. They have carved out 53 units, from one bedroom to three bedrooms, in the old landmark. While the units are sold as vacation club units, there are nearly always some available for a night or two.

Christmas season is one of my favorite times to visit San Francisco. Instead of staying near shopper-choked Union Square, we booked a three-bedroom unit that came complete with a balcony to the factory’s roof underneath the clock tower. The full kitchen and dining room were a meeting place for family and friends to play house in the factory.

The apartments are beautiful, with hardwood floors and exposed red brick. But there’s also luxurious bedding, deep bathtubs and a fireplace to make you feel toasty on a cold San Francisco day. Many of the guests congregated on the patios around the building, where fire pits burned into the night.

If you wanted for anything sweet, it was simply down the staircase to the chocolate shop or, as a change of pace, over to Kara’s Cupcakes, which made flour and frosting seem like ornaments just out of a jewel box.

Ghirardelli Square is close to Fisherman’s Wharf, but not like it. There’s none of the tacky honky-tonk atmosphere around Alioto’s and Ripley’s Believe It Or Not. There’s a kind of demarcation line of The Cannery, itself featuring the popular seafaring-themed Argonaut Hotel, adjacent to the San Francisco Maritime Museum. You can have chowder in the restaurant and then go next door and see a map of all the shipwrecks around the Golden Gate.

The neighborhood’s centerpiece is the turntable for the Powell-Hyde cable car line. Crowds wait in line to take the lurching, clanking pleasure ride over to Market Street. The lines in turn attract squadrons of street musicians and guys who paint themselves silver and stand around waiting for you to drop a dollar in their collection box. But the late autumn weather thins the crowds and those working them. It’s a more sedate experience compared to July.

Across the street from the turntable is Buena Vista, where legend has it a San Francisco newspaperman named Stanton Delaplane brought reports of a concoction of coffee and whiskey he had in the airport bar in Shannon, Ireland. The journalist and the bar’s owner worked out how to float cream on top of the booze and coffee and, in 1952, a local tradition was born. Today, a conveyor-belt-like process with glass, hot water, coffee, sugar cubes, whipped cream and whiskey churns out scores of Irish coffees in an hour.

Luckily for guests of the Fairmont Heritage Place, it’s just a short walk back to bed in the chocolate factory.